简体   繁体   English

无法导入PyQt4.QtGui

[英]Cannot import PyQt4.QtGui

I have a working Python 2.6 install and just installed the PyQt4 built for Python 2.6 (available at http://www.riverbankcomputing.co.uk/software/pyqt/download ). 我安装了可正常运行的python 2.6,并刚刚安装了为python 2.6构建的PyQt4(可从http://www.riverbankcomputing.co.uk/software/pyqt/download下载 )。 When I try to import PyQt4.QtGui I get the following error: 当我尝试导入PyQt4.QtGui时,出现以下错误:

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

I'm on Windows 2k8 64-bit, but my Python install is 32-bit. 我使用的是Windows 2k8 64位,但是我的Python安装是32位。

Add the the PyQt4 directory containing Qt's applications and DLLs to your PATH environment variable. 将包含Qt应用程序和DLL的PyQt4目录添加到PATH环境变量中。 In PowerShell, provided you didn't change any of your install paths, that'd be 在PowerShell中,只要您不更改任何安装路径,就可以

$env:path += ';C:\Python26\Lib\site-packages\PyQt4\bin'

I found a solution on another forum that worked for me. 我在另一个对我有用的论坛上找到了解决方案。 I needed to copy QtGui4.dll and QtCore4.dll into the ...\\Python2.7.1\\Lib\\site-packages\\PyQt4 directory. 我需要将QtGui4.dll和QtCore4.dll复制到... \\ Python2.7.1 \\ Lib \\ site-packages \\ PyQt4目录中。 Note, I left the original in the bin directory. 注意,我将原始文件保留在bin目录中。

I had installed PyQt4 from a .whl file (from the unofficial windows binaries ) and got the same error. 我已经从.whl文件(从非官方的Windows二进制文件 )安装了PyQt4,并遇到了相同的错误。

I did what the answers suggested: checked that I installed the correct version, put my PyQt4 directory in the PATH environment variable and had QtCore4.dll and QtGui4.dll , however none of these worked. 我做了回答的建议:检查我安装了正确的版本,将我的PyQt4目录放在PATH环境变量中,并且具有QtCore4.dllQtGui4.dll ,但是这些都QtCore4.dll

The answer was to try and open the designer.exe program: it also had an error, but this time specified which DLL file was missing (it said msvcp140.dll is missing from your computer ) 答案是尝试打开designer.exe程序:它也有一个错误,但是这次指定了哪个DLL文件丢失了(它说msvcp140.dll is missing from your computer

I then downloaded it off dll-files.com and put it in the PyQt4 folder ( C:\\Python35\\Lib\\site-packages\\PyQt4 ) and it worked. 然后,我从dll-files.com下载了该文件 ,并将其放在PyQt4文件夹( C:\\Python35\\Lib\\site-packages\\PyQt4 )中,它可以正常工作。

I hope this helps ! 我希望这有帮助 !

Are you sure you installed Python x64 ? 您确定安装了Python x64吗? By default, the Python website makes you download the x32 version, you need to go to this page to download the x64 version and then it will work. 默认情况下,Python网站允许您下载x32版本,您需要转到此页面下载x64版本,然后它才能工作。 I had the same issue and it was fixed this way. 我遇到了同样的问题,并且这种问题已得到解决。 https://www.python.org/downloads/windows/ https://www.python.org/downloads/windows/

Hope that will help someone. 希望能对某人有所帮助。 Cheers, Chris 克里斯,干杯

If this does not works, try search for QtCore4.dll, QtGui4.dll, etc. in your paths set in PATH environment variable. 如果这不起作用,请尝试在PATH环境变量中设置的路径中搜索QtCore4.dll,QtGui4.dll等。 In my case I found some qt dll in c:\\windows\\system32, caused the same error message. 就我而言,我在c:\\ windows \\ system32中找到了一些qt dll,导致了同样的错误消息。 I've deleted the dll files, and problem solved. 我已经删除了dll文件,问题已解决。 'C:\\Python26\\Lib\\site-packages\\PyQt4\\bin' was in my path, but that was not enough. 'C:\\ Python26 \\ Lib \\ site-packages \\ PyQt4 \\ bin'在我的路径中,但这还不够。

Download the program from http://www.dependencywalker.com to see if there was missing dll. http://www.dependencywalker.com下载该程序,以查看是否缺少dll。

You need to point the program to the QtGui.pyd file from PyQt. 您需要将程序指向PyQt的QtGui.pyd文件。

My case was using MSYS2's mingw-w64-x86_64-python3-pyqt4, it needed libpython3.5m.dll while pacman was already at python3.6 我的情况是使用MSYS2的mingw-w64-x86_64-python3-pyqt4,它需要libpython3.5m.dll,而pacman已经在python3.6上了

Neither of the these solutions worked for me. 这些解决方案都不适合我。 I had Python 3.1 x64 with PyQt 4.8.2-1 x64 on my Windows 7 x64, but uninstalling them and installing the x86 versions of Python 3.1 and PyQt solved the problem for me. 我在Windows 7 x64上安装了带有PyQt 4.8.2-1 x64的Python 3.1 x64,但是卸载它们并安装x86版本的Python 3.1和PyQt可以为我解决问题。

I usage Linux ubuntu 14.04,firstly, Cannot import PyQt4.QtGui because access module PyQt4 not Available in group permission.. if call interpreter: shell>> python not available module QtGui, but if i call interpreter sudo python available QtGui.So, I solved this error , Change permisions folder package PyQt4 in my virtualenv,from property folder,change Owner and Group . 我使用Linux操作系统Ubuntu 14.04,首先,无法导入PyQt4.QtGui因为接入模块PyQt4中没有可用的组权限。如果调用解释: shell>> python不可模块QtGui,但如果我打电话解释sudo python可以QtGui.So,我解决了此错误, Change permisions folder package PyQt4 in my virtualenv,from property folder,change Owner and Group

Its works for me :) 它对我有用:)

None of these solutions worked for me with 64bit Python 3.5. 这些解决方案都不适用于64位Python 3.5。 I ended up rolling back Anaconda to 4.1.1 (4.2.0 uses a Qt5 by default, which may or may not be the problem). 我最终将Anaconda回滚到4.1.1(默认情况下4.2.0使用Qt5,这可能是问题,也可能不是问题)。 I also had to install pyqt from a python 3.5 whl - http://www.lfd.uci.edu/%7Egohlke/pythonlibs/#pyqt4 . 我还必须从python 3.5 whl- http: //www.lfd.uci.edu/%7Egohlke/pythonlibs/#pyqt4安装pyqt。

The binary file on the Riverbank website did not work for me, possibly it only works on Python 3.4? Riverbank网站上的二进制文件不适用于我,可能仅适用于Python 3.4?

I have installed pyqt with Anaconda several times, and I believe if it is done correctly the PATH does not need modification (it happens as part of installation) and DLLs do not need to be copied. 我已经用Anaconda多次安装了pyqt,我相信如果正确完成,PATH不需要修改(安装过程中会发生),并且不需要复制DLL。

您是否验证了PyQt4是用于32位还是64位的?我遇到了同样的问题,我在Windows 10和PyQt4 4.11 64位中使用了python 2.7.13 32位,并将PyQt4更改为32位,并且可以立即使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM