PyQt 4.7 - ImportError after installing on Windows

谁说胖子不能爱 提交于 2019-11-30 18:07:11

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...

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!