I've upgraded to Python 2.7 from Python 2.6 on Ubuntu Maverick Meerkat (10.10) and I'm unable to import PyQt4.
austin@gerald:~$ python2.7
Python 2.7.0+ (r27:82500, Sep 15 2010, 18:04:55)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PyQt4
I installed both Python 2.7 (python2.7) and PyQt4 (python-qt4) from the Ubuntu repositories. I installed PyQt a while back, but I installed Python 2.7 recently.
If I try Python 2.6 (since it's shipped with Ubuntu, the command is simply python), it works perfectly. Watch:
austin@gerald:~$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
I know what the problem is: the PyQt4 modules are accessible by Python 2.6 but not 2.7. My question is, how do I get Python 2.7 to find the PyQt4 module(s)? Help!
Note: sorry if this belongs in Super User, I was just programming when I encountered this problem.
PyQt4 is a comprehensive set of Python bindings for Digia's Qt cross platform GUI toolkit. PyQt4 supports Python v2 and v3.
Can I install PyQt4 and PyQt5 together? Co-existence with PyQt4 PyQt5 can be installed alongside PyQt4 using the same Python interpreter without any problems so long as they are built with the same version of SIP.
The error "Could not find a version that satisfies the requirement PyQt6" is often caused due to not having the necessary permissions to install a package for all users on the machine. To solve the error, install the package scoped to the specific user with the --user option.
As PyQt is not using setup.py it cannot be installed using pip or easy_install
Here you have a tutorial showing how to build and install PyQt for python2.7:
http://problemssol.blogspot.com/2010/12/compile-and-install-pyqt4-for-python27.html
Update: For Ubuntu 12.04+ just use apt-get:
apt-get install python-qt4
Under Ubuntu system, you could install it via apt-get
apt-get install python-qt4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With