【问题标题】:Python3.5 on Win7x64 can not load from Qt5 module QtWidgetsWin7x64上的Python3.5无法从Qt5模块QtWidgets加载
【发布时间】:2015-09-15 09:43:52
【问题描述】:

我已经安装了 python 3.5.0

Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32

然后安装Qt5:pip install python-qt5。

这里的代码:

import sys
from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
button = QtWidgets.QPushButton("Hello")
button.setFixedSize(400, 400)
button.show()
app.exec_()

返回错误:

C:\Python35\python.exe C:/py_test/test_qt5/main.py
Traceback (most recent call last):
  File "C:/py_test/test_qt5/main.py", line 2, in <module>
    from PyQt5 import QtWidgets
ImportError: DLL load failed: The specified module could not be found.

这是我的路径:

C:\Python35\Scripts\;C:\Python35\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0 \;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Skype\Phone\;C:\Python35\Lib\站点包\PyQt5\;

请注意。 谢谢

更新: 我在 C:\Python35\Lib\site-packages\PyQt5 中有 Qt5Widgets.dll 和 QtWidgets.pyd

【问题讨论】:

    标签: windows qt python-3.x pyqt5


    【解决方案1】:

    您在C:\Python35\Lib\site-packages\PyQt5\ 中有二进制文件还是在C:\Python35\Lib\site-packages\PyQt5\bin 中?

    检查C:\Python35\Lib\site-packages\PyQt5\bin 是否存在并将路径添加到您的环境PATH 变量。

    【讨论】:

    • 我在 C:\Python35\Lib\site-packages\PyQt5\ 中有二进制文件/dll,并且没有 bin\ 目录 C:\Python35\Lib\site-packages\PyQt5\ 存在路径变量
    • 我已重新安装到 x86 python35,并收到“ImportError: DLL load failed: %1 is not an valid Win32 application.”现在
    • 嘿,我使用的是 python 3.6,我在 C:\Python35\Lib\site-packages\PyQt5\Qt\bin 中找到了 bin 文件夹。因此,请尝试将其添加到 Windows 7 中的环境变量路径
    【解决方案2】:

    因此,PyQt5 将不适用于 python3.5

    降级到 python 3.4 解决了问题

    【讨论】:

    • 很高兴听到您解决了这个问题 :) 编码愉快!
    猜你喜欢
    • 1970-01-01
    • 2021-04-21
    • 2017-10-20
    • 2011-03-08
    • 1970-01-01
    • 1970-01-01
    • 2021-01-11
    • 2015-02-09
    • 1970-01-01
    相关资源
    最近更新 更多