Python 2.7 non può importare PyQt4
-
25-09-2019 - |
Domanda
ho aggiornato a Python 2.7 da Python 2.6 su Ubuntu Maverick Meerkat (10.10) e sono in grado di importare 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 installato sia Python 2.7 (python2.7) e PyQt4 (python-qt4) dai repository di Ubuntu. Ho installato PyQt una schiena po ', ma ho installato Python 2.7 di recente.
Se provo Python 2.6 (dal momento che è fornito con Ubuntu, il comando è semplicemente python ), funziona perfettamente. Orologio:
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
Lo so qual è il problema: i moduli PyQt4 sono accessibili con Python 2.6, ma non 2.7. La mia domanda è: come faccio ad avere Python 2.7 per trovare il modulo PyQt4 (s)? Aiuto!
Nota. Dispiace se questo appartiene a Super User, stavo solo di programmazione, quando ho incontrato questo problema
Soluzione
Con il sistema Ubuntu, si potrebbe installare tramite apt-get
apt-get install python-qt4
Altri suggerimenti
Come PyQt non utilizza setup.py non può essere installato utilizzando pip o easy_install
Ecco un tutorial che mostra come costruire e installare PyQt per python2.7:
http: //problemssol.blogspot .com / 2010/12 / compilazione e-install-PyQt4-per-python27.html
Aggiornamento: Per Ubuntu 12.04+ basta usare apt-get:
apt-get install python-qt4
OSX 10.8.2 testato:
sudo pip install SIP
ottenuto IOError: [Errno 2] Nessun file o directory: '/tmp/pip-build/SIP/setup.py'
E 'ok allora:
cd /tmp/pip-build/SIP
sudo python configure.py
make
sudo make install
scaricare PyQt da: http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.9.6/PyQt-mac-gpl-4.9.6.tar.gz
unzip esso.
cd PyQt-mac-gpl-4.9.6
sudo python configure.py
make
ci vorrà un po ', dopo il make poi:
sudo make install
Buon divertimento:)
È possibile scaricare qualsiasi versione di PyQt4 qui per qualsiasi versione di Python, ma dal momento che lei ha chiesto per Python 2.7, Ecco il link per il download per Python 2.7:
https://sourceforge.net/projects/pyqt/files /PyQt4/PyQt-4.11.4/
È necessario installare PyQt4 nel 2.7 ambiente Python. Per fare questo percorso
easy_install2.7 PyQt4
Se easy_install non è installato è necessario prima scaricare e installare eseguendo
python2.7 setup.py install
Si prega di installare il modulo SIP prima, questo è pitone e C / C ++ lib strumenti, e PyQt4 lib