PyQt 4.7 - 在 Windows 上安装后出现导入错误

发布于 2024-08-19 02:29:32 字数 520 浏览 11 评论 0原文

我一直在尝试在 Vista 上安装 PyQt 4.7,但是当我尝试执行以下操作时遇到导入错误:from PyQt4 import QtCore, QtGui

导入错误:DLL 加载失败:找不到指定的模块。

我检查了我的系统路径,C:\Python31\Lib\site-packages\PyQt4\bin 就在那里。

我无法运行任何示例,但设计器、助理和语言学家运行良好。

我正在使用 ActivePython 3.1,如果这有什么区别的话。而且我还没有安装任何以前版本的 PyQt。


编辑:

我已将 QtCore4 和 GtGui4 dll 复制到 C:\Python31\Lib\site-packages\ PyQt4。这修复了一些示例,但我仍然无法使用示例浏览器。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

好久不见√ 2024-08-26 02:29:32

您确定您的 PyQt 版本有一个 \bin 目录吗?
我正在运行 PyQt 4.4,并且我的所有二进制文件都位于:

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

这也是我的路径所指向的。
听起来 PyQt4 安装不正确......你运行了这个吗?

python setup.py install

那里不应该有一个垃圾箱......

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

南薇 2024-08-26 02:29:32

只是想提醒一下,我在 WinXP 安装时遇到了同样的问题:

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

我使用了所有 3 个项目的 Windows 安装程序版本。

C:\Python27\Lib\site-packages\PyQt4\bin 文件夹的内容复制到主 PyQt 文件夹 (C:\Python27\Lib\site-packages\PyQt4< /strong>) 停止了 python 抛出的“dll not found”错误。

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.

葬花如无物 2024-08-26 02:29:32

我也插话。我使用 Windows 安装程序在 Windows 7 计算机上安装了 python 2.6 和 PyQt 4.8.3(我没有运行“python setup.py install”)。

我尝试运行spyder(需要 PyQt 4.4 或更高版本)但失败,因为它找不到 PyQt .dll。我将所有 .dll 从 \Lib\site-packages\PyQt4\bin 文件夹复制到 \Lib\site-packages\PyQt4 文件夹,spyder 启动得很好。

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.

从此见与不见 2024-08-26 02:29:32

PyQt的安装还取决于您平台上安装的python版本。Python3.+与Python版本不兼容< 3.x。

我遇到了同样的问题,因为我的机器上安装了 Python 2.7,但我下载了最新的二进制文件 PyQt-Py3.2-x86-gpl-4.9.exe。如果您在这里看到二进制文件,则在 PyQt 之后的名称中也提到了 python 版本,即 Py3.2。我卸载了 PyQt 并安装了 PyQt-Py2.7-x86-gpl-4.9.exe,它指向 Python 2.7,它解决了问题。

也许他们可以在网上或在某些文档中提到命名约定,这样会更简单。

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.

℡Ms空城旧梦 2024-08-26 02:29:32

我也有同样的问题。我从 Eclipse 中运行我的程序,但是当我尝试直接从命令行运行它时,我仍然遇到相同的错误。

我通过重命名 C:\Users\Me\AppData\Roaming\Python\Python27\site-packages\PyQt4 目录解决了这个问题。 (我猜是之前 PyQt 安装的剩余部分)

我正在使用 ActivePython。

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.

执着的年纪 2024-08-26 02:29:32

我认为至少有两种可能的错误情况

1。 ImportError: DLL load failed: 找不到指定的模块。

那么你必须检查你的 PyQT 版本是否与你的 python 兼容。换句话说,如果你使用python 3.3,那么你只能使用PyQT for python3.3,而python 3.3将无法使用PyQT for python3.4

这就是我遇到的问题。我通过重新安装解决了它

2。导入错误:DLL 加载失败:%1 然后在不同的编码 Win32 上出现奇怪的情况。

那么这将是操作系统问题。如果你使用32位Python那么你必须使用32位PyQt,64位也是如此

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

与往事干杯 2024-08-26 02:29:32

以下是我在 Windows 7 上修复这些错误的方法:

  1. 从以下位置获取 PyQt4 轮
    http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4
    确保该版本与您的 Python 版本完全相同(即 Python 3.3 不适用于 Python 3.4 的 PyQT)。如果您使用的是 64 位计算机,请务必下载 64 位版本,反之亦然。
  2. 使用 7zip 提取轮子 将
  3. PyQt4-4.11.4.data (或类似)目录重命名为 PyQt4
  4. 转到 PyQt4\purelib\PyQt4\ 并将所有内容移动到根 PyQt4 文件夹。您现在可以删除 purelib 文件夹
  5. 将整个 PyQt4 文件夹复制到 Python 解释器的“site-packages”文件夹(例如 C:\Python34\Lib\site-packages)
  6. 转到 PyQt4\data\Lib\site-packages 并移动所有文件到 C:\Python34\Lib\site-packages\

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\
长不大的小祸害 2024-08-26 02:29:32

就我而言,我需要 MSVCP140.dll。我通过下载 Visual C++ Redistributable for Visual Studio 2015 解决了这个问题:

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

MSVCP140.dll丢失

我在Windows7中使用Pyqt4和Python 3.6。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文