Python PyQt5:DLL加载失败:找不到指定的模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36666225/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 18:11:43  来源:igfitidea点击:

PyQt5: The DLL load failed: the specified module could not be found

pythonpython-3.xmodulepyqtpyqt5

提问by Ahmad Taha

I recently installed the PyQt5 module setup for 32-Bitcomputers on Windows. But when I am trying to run their examples none of thenwould run. All of the examples provided were having the similartype of error as in the following image. And when I tried to import PyQt5 in the Python shell it just imported correctly.

我最近在Windows上为32 位计算机安装了 PyQt5 模块设置。但是当我试图运行他们的例子时,没有一个会运行。提供的所有示例都具有与下图类似的错误类型。当我尝试在 Python shell 中导入 PyQt5 时,它刚刚正确导入。

Enter image description here

在此处输入图片说明

I think this shows PyQt is installed successfully.

我认为这表明 PyQt 已成功安装。

But when i try to run the examples it shows like:

但是当我尝试运行示例时,它显示如下:

enter image description here

在此处输入图片说明

This is of one example and other examples have different 'no founds'

这是一个例子,其他例子有不同的“无发现”

Facts- Running Windows 7, PyQt5 latest version, Python 3.5, Installed PyQt5 from original site with setup

事实- 运行 Windows 7、PyQt5 最新版本、Python 3.5、从原始站点安装 PyQt5 并进行设置

I know there are several questions of such type, but none helped me because most of them were for Linux.

我知道有几个此类问题,但没有一个对我有帮助,因为其中大部分是针对 Linux 的。

回答by Ahmad Taha

I got the answer to my own question.

我得到了我自己问题的答案。

When I tried to install it by setup, it did not ran properly. Then I uninstalled the setup and also ran the code in command line pip uninstall pyqt5and then reinstalled by pip pip install pyqt5.

当我尝试通过安装程序安装它时,它没有正常运行。然后我卸载了安装程序并在命令行中运行了代码pip uninstall pyqt5,然后通过 pip 重新安装pip install pyqt5

Then it perfectly ran, but by installing with pip it doesn't provide any examples so for that install the setup in any other directory and copy the examples in the PyQt5 folder. Done!

然后它完美运行,但是通过使用 pip 安装它不提供任何示例,因此在任何其他目录中安装设置并将示例复制到 PyQt5 文件夹中。完毕!

I think there may be some bug in the setup.

我认为设置中可能存在一些错误。

回答by Siva Manasan

Plese always make sure you are downloading the correct version of PyQtwhich is compatible with the python version you have, Curren PqQt only supports up to python 3.5.So you may need to install python 3.5 first and then follow the installation of PyQt.Hope it helps!

请务必确保您正在下载与您拥有的 python 版本兼容的正确版本的 PyQt,Curren PqQt 最多只支持 python 3.5。所以您可能需要先安装 python 3.5,然后再 安装 PyQt。希望它有帮助!

回答by Ed Randall

I experienced similar difficulties trying to install PyQt5 into an existing Python3.6 installation on Windows10 at C:\apps\Python36

我在尝试将 PyQt5 安装到 Windows10 上的现有 Python3.6 安装中时遇到了类似的困难 C:\apps\Python36

  1. Don't install the download from https://www.riverbankcomputing.com/software/pyqt/download5and if you have already installed it, uninstall using Windows Control Panel>Programs>Uninstall

  2. Open a new CMD prompt and ensure your PATH is set to include Python and Scripts

  1. 不要从https://www.riverbankcomputing.com/software/pyqt/download5安装下载,如果您已经安装,请使用 Windows控制面板>程序>卸载卸载

  2. 打开一个新的 CMD 提示符并确保您的 PATH 设置为包含 Python 和脚本

PATH=C:\apps\Python36;C:\apps\Python36\Scripts;%PATH%

PATH=C:\apps\Python36;C:\apps\Python36\Scripts;%PATH%

  1. In the CMD shell, install PyQt5 using pip: pip install PyQt5. Afterwards check the installed packages:
  1. 在 CMD shell 中,使用 pip: 安装 PyQt5 pip install PyQt5。然后检查已安装的软件包:
     C:\>pip list
     Package    Version
     ---------- -------
     pip        10.0.1
     PyQt5      5.11.2
     PyQt5-sip  4.19.12
     setuptools 28.8.0
  1. There is a 'Hello World' program at https://www.tutorialspoint.com/pyqt/pyqt_hello_world.htmbut it results in many errors like: AttributeError: module 'PyQt5.QtGui' has no attribute 'QApplication'due to PyQt4/5 changes. Try this instead:
  1. https://www.tutorialspoint.com/pyqt/pyqt_hello_world.htm 上有一个“Hello World”程序,但它会导致许多错误,例如:AttributeError: module 'PyQt5.QtGui' has no attribute 'QApplication'由于 PyQt4/5 更改。试试这个:
     import sys
     from PyQt5 import QtWidgets

     def window():
        app = QtWidgets.QApplication(sys.argv)
        w = QtWidgets.QWidget()
        b = QtWidgets.QLabel(w)
        b.setText("Hello World!")
        w.setGeometry(100,100,200,50)
        b.move(50,20)
        w.setWindowTitle("PyQt")
        w.show()
        sys.exit(app.exec_())

     if __name__ == '__main__':
        window()
  1. For further details of changes between PyQt4 and PyQt5 see http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html
  1. 有关 PyQt4 和 PyQt5 之间更改的更多详细信息,请参阅http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html

回答by ru13r

I had a similar issue.

我有一个类似的问题。

Everything worked when I completely uninstalled 32-bit version of Python, installed a 64-bit one, and reinstalled all the packages for amd64, including the PyQt5.

当我完全卸载 32 位版本的 Python、安装一个 64 位版本并重新安装 amd64 的所有包(包括 PyQt5)时,一切正常。