简体   繁体   English

ImportError PyQt5蟒蛇

[英]ImportError PyQt5 Anaconda

I am trying to use PyQt5 installed via pip in an Anaconda enviroment on Windows 10 x64. 我正在尝试在Windows 10 x64的Anaconda环境中使用通过pip安装的PyQt5。 This is how i create my environemnt: 这就是我创建环境的方式:

conda create --name qt python=3.6
activate qt
pip install pyqt5

When running an example application i get an error: 当运行示例应用程序时,出现错误:

File "pyqt_test.py", line 16, in from PyQt5.QtWidgets import QApplication, QWidget ImportError: DLL load failed: The specified module could not be found. 从PyQt5.QtWidgets导入QApplication,QWidget ImportError进入文件“ pyqt_test.py”,第16行,DLL加载失败:找不到指定的模块。

Installing Python by downloading it from python.org and then installing pyqt5 works as expected. 通过从python.org下载Python进行安装,然后安装pyqt5可以按预期工作。

Thanks for the help. 谢谢您的帮助。

Just run into the same problem, Miloslav is right about the problem, actually it seems that conda should maybe provide a python3.dll as well, see here for the discussion https://github.com/ContinuumIO/anaconda-issues/issues/1394 . 只是遇到了同样的问题,米洛斯拉夫对这个问题是正确的,实际上似乎conda也应该提供python3.dll,请参阅此处的讨论https://github.com/ContinuumIO/anaconda-issues/issues/ 1394

In short just use conda to install pyqt5 by running: 简而言之,只需运行以下命令即可使用conda安装pyqt5:

conda install pyqt

this install the latest pyqt bindings which is currently pyqt 5.6 这将安装最新的pyqt绑定,当前是pyqt 5.6

It is because of missing Python3.dll (stub dll, that re-exports Python3x.dll functions, so that one version of extension can work for multiple versions of python). 这是因为缺少Python3.dll (存根dll,重新导出了Python3x.dll函数,因此扩展的一个版本可以适用于多个版本的python)。

If your Python distro doesn't bundle python3.dll, you can try one from WinPython ( https://winpython.github.io/ ). 如果您的Python发行版未捆绑python3.dll,则可以从WinPython( https://winpython.github.io/ )中尝试一个。

At least the 2017/04/01 versions should have it. 至少2017/04/01版本应该有它。

1) Download WinPython ('Zero' version suffices; must be same "main version" - 3.5/3.6 -and "bitness" - 32/64 - as your Python !!!). 1)下载WinPython(“零”版本已足够;必须与Python相同的“主版本”-3.5 / 3.6-和“位数”-32/64-!!!)。

2) Extract to some temp directory, take the python3.dll and stick it into your python dir, next to the python3x.dll. 2)解压缩到一些临时目录,获取python3.dll并将其粘贴到python3x.dll旁边的python目录中。

3) Enjoy working QT 3)享受工作QT

In my case,Firstly i installed pyqt: 就我而言,首先我安装了pyqt:

conda install pyqt

Then i deleted the qt.conf file located next to python.exe. 然后我删除了位于python.exe旁边的qt.conf文件。 Next pyqt5 installation succeeded: 下一次pyqt5安装成功:

conda install pyqt5

ref: https://github.com/ContinuumIO/anaconda-issues/issues/138 参考: https : //github.com/ContinuumIO/anaconda-issues/issues/138

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

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