Reputation: 527
I've reïnstalled my ssh server, so I also need to reïnstall my Python packages.
I did that, but I still get the error:
ImportError: No module named PyQt4.QtCore
I've already successfully installed:
sudo apt-get install libqt4-dev
But still it don't work, so I tried the installation instruction of PyQt4
So I've tried to install SIP first, but when I run "make" (see end of this page, "Building")
But I get this error:
make[1]: Entering directory `/home/francis/Downloads/sip-4.12.4/sipgen'
g++ -o sip main.o transform.o gencode.o extracts.o export.o heap.o parser.o lexer.o
make[1]: g++: Command not found
make[1]: *** [sip] Error 127
make[1]: Leaving directory `/home/francis/Downloads/sip-4.12.4/sipgen'
make: *** [all] Error 2
What do I have to do? Or is there an other way to install PyQt4?
Thanks!
Upvotes: 23
Views: 121892
Reputation: 113
Try this command to solve your problem.
sudo apt install build-essential python3-dev libqt4-dev
This works for me in python3.
Upvotes: 0
Reputation: 441
I was having the same error - ImportError: No module named PyQt4.QtGui
. Instead of running your python file (which uses PyQt) on the terminal as -
python file_name.py
Run it with sudo privileges -
sudo python file_name.py
This worked for me!
Upvotes: 14
Reputation: 9338
I had the same issue when uninstalled my Python27 and re-installed it.
I downloaded the sip-4.15.5 and PyQt-win-gpl-4.10.4 and installed/configured both of them. it still gives 'ImportError: No module named PyQt4.QtCore'. I tried to move the files/folders in Lib to make it looked 'have' but not working.
in fact, jut download the Windows 64 bit installer for a suitable Python version (my case) from http://www.riverbankcomputing.co.uk/software/pyqt/download and installed it, will do the job.
* March 2017 update *
The given link says, Binary installers for Windows are no longer provided.
See cgohlke's answer at, PyQt4 and 64-bit python.
Upvotes: 4
Reputation: 1495
I got the same error, when I was trying to import matplotlib.pyplot
In [1]: import matplotlib.pyplot as plt
...
...
ImportError: No module named PyQt4.QtCore
But in my case the problem was due to a missing linux library libGL.so.1
OS : Cent OS 64 bit
Python version : 3.5.2
$> locate libGL.so.1
If this command returns a value, your problem could be different, so please ignore my answer. If it does not return any value and your environment is same as mine, below steps would fix your problem.
$> yum install mesa-libGL.x86_64
This installs the necessary OpenGL libraries for 64 bit Cent OS.
$> locate libGL.so.1
/usr/lib/libGL.so.1
Now go back to iPython and try to import
In [1]: import matplotlib.pyplot as plt
This time it imported successfully.
Upvotes: 0
Reputation: 2055
I had the "No module named PyQt4.QtCore" error and installing the python-qt4 package fixed it only partially: I could run
from PyQt4.QtCore import SIGNAL
from a python interpreter but only without activating my virtualenv.
The only solution I've found till now to use a virtualenv is to copy the PyQt4 folder and the sip.so file into my virtualenv as explained here: Is it possible to add PyQt4/PySide packages on a Virtualenv sandbox?
Upvotes: 2
Reputation: 39548
As mentioned in the comments, you need to install the python-qt4
package - no need to recompile it yourself.
sudo apt-get install python-qt4
Upvotes: 33
Reputation: 825
You don't have g++ installed, simple way to have all the needed build tools is to install the package build-essential:
sudo apt-get install build-essential
, or just the g++ package:
sudo apt-get install g++
Upvotes: 1