0

I need to be able to use the latest WebKit that includes WebRTC support

How do I install Qt5+QtPy5 on Raspbian?

What I have tried so far...

Installed Qt5 on RPi2 - PASS

Native build Qt5 on RPi2 HERE

Installed PyQt5 using pip - PASS

$ sudo apt-get install python-pip

and then

pi@raspberrypi ~/VerySimpleBrowser $ sudo pip install python-qt5
Downloading/unpacking python-qt5
  Running setup.py egg_info for package python-qt5

Installing collected packages: python-qt5
  Running setup.py install for python-qt5

Successfully installed python-qt5
Cleaning up...

location doesn't seem right, I'd expect it to be in lib/python3 (?)

pi@raspberrypi /usr/local/lib/python2.7/dist-packages $ ls -al
total 16
drwxrwsr-x 4 root staff 4096 May  8 16:36 .
drwxrwsr-x 4 root staff 4096 Jan  1  1970 ..
drwxr-sr-x 5 root staff 4096 May  8 16:36 PyQt5
drwxr-sr-x 2 root staff 4096 May  8 16:36 python_qt5-0.1.8.egg-info

I tried moving these to /usr/local/lib/python3.2/dist-packages, cause that's where I expected them to be (may be not a good idea, but I had to try).

python installations

pi@raspberrypi /usr/local/lib $ ls -al
total 24
drwxrwsr-x  6 root staff 4096 May  8 16:14 .
drwxrwsr-x 10 root staff 4096 May  8 16:36 ..
drwxrwsr-x  4 root staff 4096 May  8 16:14 python2.6
drwxrwsr-x  4 root staff 4096 Jan  1  1970 python2.7
drwxrwsr-x  3 root staff 4096 Jan  1  1970 python3.2   <====

Tested and got an error

 $ python3.2
Python 3.2.3 (default, Mar  1 2013, 11:53:50) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> from PyQt5 import QtCore, QtGui, QtWebKit
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name QtCore
>>> 

and with Python 2.7

pi@raspberrypi ~ $ python
Python 2.7.3 (default, Mar 18 2014, 05:13:23) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> from PyQt5 import QtCore, QtGui, QtWebKit
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name QtCore

Any pointers?

4

You did a couple things wrong. First off, running sudo pip install python-qt5 made Python2.7's pip download. You can in future avoid this with py -3 -m pip install python-qt5. py is a very useful tool when you have multiple Python versions.

The next thing you did wrong was copying the Python2.7 modules to your Python3.x lib, most modules (especially big complex ones such as PyQt, have version specific code that won't work. Never copy modules from one release to another unless you are sure that it is version agnostic. This also applies between sub-version releases (like 2.6 and 2.7).

Finally, I will get to the solution. What you didn't know, and is hard to figure out, is that PyQt5's binaries are Windows only right now. However, you can compile from source yourself, just follow this guide.

These instructions are for Ubuntu 12.04, so skip the installation of Qt, since you already have that (Start at step 2). I don't have a Pi 2 yet (I am hoping to get one!)but that should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.