Frage

Ich habe mit Python Upgrade 2.7 von Python 2.6 auf Ubuntu Maverick Meerkat (10.10) und ich bin nicht in der Lage PyQt4 zu importieren.

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

Ich installierte sowohl Python 2.7 (python2.7) und PyQt4 (python-qt4) aus den Ubuntu-Repositories. Ich installierte PyQt eine Weile zurück, aber ich installierte Python 2.7 vor kurzem.

Wenn ich versuche, Python 2.6 (da es mit Ubuntu ausgeliefert ist, ist der Befehl einfach Python ), es funktioniert perfekt. 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

Ich weiß, was das Problem ist: Die PyQt4 Module sind mit dem Python 2.6, aber nicht 2.7. Meine Frage ist, wie bekomme ich Python 2.7 PyQt4 Modul (e) zu finden? Hilfe!

. Hinweis: sorry, wenn dies in Super User gehört, ich habe nur die Programmierung, wenn ich dieses Problem aufgetreten

War es hilfreich?

Lösung

Unter System Ubuntu, können Sie es über apt-get

installieren
apt-get install python-qt4

Andere Tipps

Wie PyQt verwendet nicht setup.py es nicht installiert werden kann pip mit oder easy_install

Hier haben Sie ein Tutorial zeigt, wie PyQt für python2.7 zu bauen und zu installieren:

http: //problemssol.blogspot .com / 2010/12 / Compile-and-install-PyQt4-for-python27.html

Update: Für Ubuntu 12.04+ nur apt-get:

apt-get install python-qt4

OSX 10.8.2 getestet:

sudo pip install SIP

got IOError: [Errno 2] Datei oder Verzeichnis: '/tmp/pip-build/SIP/setup.py'

Es ist in Ordnung, dann:

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

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

unzip es.

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

es wird eine Weile dauern, nach make dann:

sudo make install    

Genießen Sie es:)

Sie können eine beliebige Version von PyQt4 hier herunterladen für jede Version von Python, aber da Sie für Python 2.7 gefragt, Hier ist der Link für den Download für Python 2.7:

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

Sie sollten PyQt4 in Python 2.7-Umgebung installieren. Um dies zu tun run

easy_install2.7 PyQt4

Wenn easy_install nicht installiert Sie zum ersten Download benötigt und installieren Sie es, indem Sie

python2.7 setup.py install

Bitte installieren Sie SIP-Modul zuerst, dieser Python und C / C ++ lib Tools und PyQt4 lib

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top