Question

I've been trying to install PyQt 4.7 on Vista, but I am getting an ImportError when I try to do: from PyQt4 import QtCore, QtGui.

ImportError: DLL load failed: The specified module could not be found.

I've checked my System Path, and C:\Python31\Lib\site-packages\PyQt4\bin is on there.

I can't run any of the examples, but the Designer, Assistant and Linguist run fine.

I am using ActivePython 3.1, if that makes any difference. And I haven't had any previous version of PyQt installed.


Edit:

I've copied the QtCore4 and GtGui4 dlls to C:\Python31\Lib\site-packages\PyQt4. That fixes some of the examples, but I still can't use the example browser.

Was it helpful?

Solution

Are you sure there is a \bin directory for your version of PyQt? I am running PyQt 4.4, and all my binaries are right in:

C:\Python31\Lib\site-packages\PyQt4

Which is what I have my path pointing too. It sounds like PyQt4 was installed improperly... did you run this?

python setup.py install

There shouldn't be a bin there...

OTHER TIPS

Just wanted to chime in that I had the same problem on a WinXP install of:

  • python 2.7
  • Qt 4.7.1 (10.05)
  • PyQt 4.8.1

I used the windows installer version of all 3 of those items.

Copying the contents of the C:\Python27\Lib\site-packages\PyQt4\bin folder up to the main PyQt folder (C:\Python27\Lib\site-packages\PyQt4) stopped the 'dll not found' errors that python was throwing.

Also chiming in. I installed both python 2.6 and PyQt 4.8.3 on a Windows 7 machine using the windows installers (I did NOT run 'python setup.py install').

I tried to run spyder (which requires PyQt 4.4 or greater) and failed because it couldn't find the PyQt .dlls. I copied all the .dlls from the \Lib\site-packages\PyQt4\bin folder to the \Lib\site-packages\PyQt4 folder, and spyder launches just fine.

PyQt installation also depends on the version of python installed on your platform.Python3.+ is incompatible with Python version < 3.x.

I was facing the same problem as I have Python 2.7 installed on my machine but I downloaded the latest binary which was PyQt-Py3.2-x86-gpl-4.9.exe. If you see here the binary has python version also mentioned in name after PyQt which is Py3.2. I uninstalled PyQt and installed PyQt-Py2.7-x86-gpl-4.9.exe which points to Python 2.7 and it fixed the problem.

Probably they could have mentioned the naming convention online or in some documentation to be more simpler.

I had the same problem. I got my program running from within Eclipse but when I tried running it directly from the command line I still got the same error.

I solved it by renaming the C:\Users\Me\AppData\Roaming\Python\Python27\site-packages\PyQt4 directory. (I'm guessing leftovers from a previous PyQt install)

I am using ActivePython.

I think there are at least two possible error conditions

1. ImportError: DLL load failed: The specified module could not be found.

then you have to check your PyQT version is comptible with your python. In other words, if you use python 3.3, then you can only use PyQT for python3.3 and python 3.3 will not work with PyQT for python3.4

This was the problem I met. I solved it with re-install it

2. Import Error: DLL load failed: %1 then something strange on a different encoding Win32.

then it would be a OS problem. If you use 32bit Python then you have to use 32bit PyQt, so do 64bit

Here's how I could fix those errors on Windows 7:

  1. Get the PyQt4 wheel from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4. Make sure that the version is exactly the same as your Python version (i.e. Python 3.3 doesn't work with PyQT for Python 3.4). Also make sure to download the 64bit version if you are on a 64bit machine and vice versa.
  2. Extract the wheel with 7zip
  3. Rename the PyQt4-4.11.4.data (or similar) directory to PyQt4
  4. Go to PyQt4\purelib\PyQt4\ and move everything to the root PyQt4 folder. You can delete the purelib folder now
  5. Copy the whole PyQt4 folder to your Python interpreters 'site-packages' folder (e.g. C:\Python34\Lib\site-packages)
  6. Go to PyQt4\data\Lib\site-packages and move all the files to C:\Python34\Lib\site-packages\

In my case I needed MSVCP140.dll. I have solved this problem by dowloading Visual C++ Redistributable for Visual Studio 2015:

https://www.microsoft.com/en-us/download/details.aspx?id=48145

Got this solution from MSVCP140.dll missing

I am using Pyqt4 and Python 3.6 in Windows7.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top