Skip to content Skip to sidebar Skip to footer

Python 2.7 Cannot Import Pyqt4

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:

Solution 1:

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

Solution 2:

Under Ubuntu system, you could install it via apt-get

apt-get install python-qt4

Solution 3:

OSX 10.8.2 tested:

sudo pip install SIP

got IOError: [Errno 2] No such file or directory: '/tmp/pip-build/SIP/setup.py'

It's ok then:

cd /tmp/pip-build/SIP
sudo python configure.py
make
sudo make install

download PyQt from: http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.9.6/PyQt-mac-gpl-4.9.6.tar.gz

unzip it.

cd PyQt-mac-gpl-4.9.6
sudo python configure.py
make

it will take a while, after make then:

sudo make install    

Enjoy it :)

Solution 4:

You can download any version of PyQt4 here for any version of Python but since you asked for python 2.7, Here is the link for the download for python 2.7:

https://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.4/

Solution 5:

You should install PyQt4 in the Python 2.7 environment. To do this run

easy_install2.7 PyQt4

If easy_install is not installed you will need to first download and install it by running

python2.7 setup.py install

Post a Comment for "Python 2.7 Cannot Import Pyqt4"