python-3.5 - ImportError: DLL 加载失败: 找不到指定的模块。无法执行脚本pyi_rth_qt5plugins

标签 python-3.5 pyqt5 pyinstaller importerror

##Python code##

import sys
from math import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import (QApplication, QDialog, QLineEdit, QTextBrowser,
        QVBoxLayout)

class Form(QDialog):
    def __init__(self, parent=None):
        super(Form, self).__init__(parent)
        self.browser = QTextBrowser()
        self.lineedit = QLineEdit("Type an expression and press Enter")
        self.lineedit.selectAll()
        layout = QVBoxLayout()
        layout.addWidget(self.browser)
        layout.addWidget(self.lineedit)
        self.setLayout(layout)
        self.lineedit.setFocus()
        self.lineedit.returnPressed.connect(self.updateUi)
        self.setWindowTitle("Calculate")

    def updateUi(self):
        try:
            text = self.lineedit.text()
            self.browser.append("%s = <b>%s</b>" % (text, eval(text)))
        except:
            self.browser.append("<font color=red>%s is invalid!</font>" % text)
        self.lineedit.setText('')

if __name__=="__main__":
    app = QApplication(sys.argv)
    form = Form()
    form.show()
    app.exec_()


## Use pyinstaller in CMD ##

C:\Users\john\Desktop\testing>pyinstaller -F --debug testing1.py
93 INFO: PyInstaller: 3.3.dev0+912586
93 INFO: Python: 3.5.0
93 INFO: Platform: Windows-7-6.1.7601-SP1
93 INFO: wrote C:\Users\john\Desktop\testing\testing1.spec
109 INFO: UPX is not available.
109 INFO: Extending PYTHONPATH with paths
['C:\\Users\\john\\Desktop\\testing', 'C:\\Users\\john\\Desktop\\testing']
109 INFO: checking Analysis
109 INFO: Building Analysis because out00-Analysis.toc is non existent
109 INFO: Initializing module dependency graph...
109 INFO: Initializing module graph hooks...
109 INFO: Analyzing base_library.zip ...
3931 INFO: running Analysis out00-Analysis.toc
4336 INFO: Caching module hooks...
4352 INFO: Analyzing C:\Users\john\Desktop\testing\testing1.py
4368 INFO: Loading module hooks...
4368 INFO: Loading module hook "hook-xml.py"...
4648 INFO: Loading module hook "hook-PyQt5.QtCore.py"...
4773 INFO: Loading module hook "hook-PyQt5.py"...
4773 INFO: Loading module hook "hook-encodings.py"...
4898 INFO: Loading module hook "hook-PyQt5.QtWidgets.py"...
4914 INFO: Loading module hook "hook-PyQt5.Qt.py"...
4914 INFO: Loading module hook "hook-pydoc.py"...
4914 INFO: Loading module hook "hook-PyQt5.QtPrintSupport.py"...
5007 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
5584 INFO: Looking for ctypes DLLs
5600 INFO: Analyzing run-time hooks ...
5600 INFO: Including run-time hook 'pyi_rth_qt5.py'
5616 INFO: Including run-time hook 'pyi_rth_qt5plugins.py'
5616 INFO: Looking for dynamic libraries
5631 WARNING: lib not found: Qt5Svg.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\imageformats\qsvg.dll
5647 WARNING: lib not found: Qt5Core.dll dependency of C:\python35\lib\site-pack
ages\PyQt5\Qt\plugins\imageformats\qsvg.dll
5662 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\imageformats\qsvg.dll
5694 WARNING: lib not found: Qt5Core.dll dependency of C:\python35\lib\site-pack
ages\PyQt5\Qt\plugins\imageformats\qtga.dll
5709 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\imageformats\qtga.dll
5725 WARNING: lib not found: Qt5PrintSupport.dll dependency of C:\python35\lib\s
ite-packages\PyQt5\Qt\plugins\printsupport\windowsprintersupport.dll
5756 WARNING: lib not found: Qt5Core.dll dependency of C:\python35\lib\site-pack
ages\PyQt5\Qt\plugins\printsupport\windowsprintersupport.dll
5772 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\printsupport\windowsprintersupport.dll
5803 WARNING: lib not found: Qt5Core.dll dependency of C:\python35\lib\site-pack
ages\PyQt5\Qt\plugins\platforms\qoffscreen.dll
5818 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\platforms\qoffscreen.dll
5850 WARNING: lib not found: Qt5Core.dll dependency of C:\python35\lib\site-pack
ages\PyQt5\Qt\plugins\imageformats\qwbmp.dll
5865 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\imageformats\qwbmp.dll
5896 WARNING: lib not found: MSVCP140.dll dependency of C:\python35\lib\site-pac
kages\PyQt5\Qt\plugins\platforms\qwindows.dll
5928 WARNING: lib not found: Qt5Core.dll dependency of C:\python35\lib\site-pack
ages\PyQt5\Qt\plugins\platforms\qwindows.dll
5959 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\platforms\qwindows.dll
5990 WARNING: lib not found: Qt5Core.dll dependency of C:\python35\lib\site-pack
ages\PyQt5\Qt\plugins\imageformats\qtiff.dll
6006 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\imageformats\qtiff.dll
6037 WARNING: lib not found: Qt5Core.dll dependency of C:\python35\lib\site-pack
ages\PyQt5\Qt\plugins\platforms\qminimal.dll
6068 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\platforms\qminimal.dll
6084 WARNING: lib not found: Qt5Core.dll dependency of C:\python35\lib\site-pack
ages\PyQt5\Qt\plugins\imageformats\qico.dll
6115 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\imageformats\qico.dll
6130 WARNING: lib not found: Qt5Svg.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\iconengines\qsvgicon.dll
6146 WARNING: lib not found: Qt5Core.dll dependency of C:\python35\lib\site-pack
ages\PyQt5\Qt\plugins\iconengines\qsvgicon.dll
6162 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\iconengines\qsvgicon.dll
6193 WARNING: lib not found: Qt5Core.dll dependency of C:\python35\lib\site-pack
ages\PyQt5\Qt\plugins\imageformats\qjpeg.dll
6224 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\imageformats\qjpeg.dll
6240 WARNING: lib not found: Qt5Core.dll dependency of C:\python35\lib\site-pack
ages\PyQt5\Qt\plugins\imageformats\qicns.dll
6255 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\imageformats\qicns.dll
6286 WARNING: lib not found: Qt5Core.dll dependency of C:\python35\lib\site-pack
ages\PyQt5\Qt\plugins\imageformats\qgif.dll
6318 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\imageformats\qgif.dll
6333 WARNING: lib not found: Qt5Core.dll dependency of C:\python35\lib\site-pack
ages\PyQt5\Qt\plugins\imageformats\qwebp.dll
6364 WARNING: lib not found: Qt5Gui.dll dependency of C:\python35\lib\site-packa
ges\PyQt5\Qt\plugins\imageformats\qwebp.dll
6520 WARNING: lib not found: Qt5Widgets.dll dependency of c:\python35\lib\site-p
ackages\PyQt5\QtWidgets.pyd
6536 WARNING: lib not found: Qt5Core.dll dependency of c:\python35\lib\site-pack
ages\PyQt5\QtWidgets.pyd
6567 WARNING: lib not found: Qt5Gui.dll dependency of c:\python35\lib\site-packa
ges\PyQt5\QtWidgets.pyd
6598 WARNING: lib not found: Qt5Core.dll dependency of c:\python35\lib\site-pack
ages\PyQt5\QtGui.pyd
6614 WARNING: lib not found: Qt5Gui.dll dependency of c:\python35\lib\site-packa
ges\PyQt5\QtGui.pyd
6645 WARNING: lib not found: Qt5PrintSupport.dll dependency of c:\python35\lib\s
ite-packages\PyQt5\QtPrintSupport.pyd
6661 WARNING: lib not found: Qt5Widgets.dll dependency of c:\python35\lib\site-p
ackages\PyQt5\QtPrintSupport.pyd
6692 WARNING: lib not found: Qt5Core.dll dependency of c:\python35\lib\site-pack
ages\PyQt5\QtPrintSupport.pyd
6708 WARNING: lib not found: Qt5Gui.dll dependency of c:\python35\lib\site-packa
ges\PyQt5\QtPrintSupport.pyd
6739 WARNING: lib not found: Qt5Core.dll dependency of c:\python35\lib\site-pack
ages\PyQt5\QtCore.pyd
6910 INFO: Looking for eggs
6910 INFO: Using Python library c:\python35\python35.dll
6910 INFO: Found binding redirects:
[]
6910 INFO: Warnings written to C:\Users\john\Desktop\testing\build\testing1\warn
testing1.txt
6926 INFO: checking PYZ
6926 INFO: Building PYZ because out00-PYZ.toc is non existent
6926 INFO: Building PYZ (ZlibArchive) C:\Users\john\Desktop\testing\build\testin
g1\out00-PYZ.pyz
7597 INFO: Building PYZ (ZlibArchive) C:\Users\john\Desktop\testing\build\testin
g1\out00-PYZ.pyz completed successfully.
7597 INFO: checking PKG
7597 INFO: Building PKG because out00-PKG.toc is non existent
7597 INFO: Building PKG (CArchive) out00-PKG.pkg
11481 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
11497 INFO: Bootloader c:\python35\lib\site-packages\PyInstaller\bootloader\Wind
ows-64bit\run_d.exe
11497 INFO: checking EXE
11497 INFO: Building EXE because out00-EXE.toc is non existent
11497 INFO: Building EXE from out00-EXE.toc
11512 INFO: Appending archive to EXE C:\Users\john\Desktop\testing\dist\testing1
.exe
11528 INFO: Building EXE from out00-EXE.toc completed successfully.

## Run the exe. ##

C:\Users\john\Desktop\testing\dist>testing1
PyInstaller Bootloader 3.x
LOADER: executable is C:\Users\john\Desktop\testing\dist\testing1.exe
LOADER: homepath is C:\Users\john\Desktop\testing\dist
LOADER: _MEIPASS2 is NULL
LOADER: archivename is C:\Users\john\Desktop\testing\dist\testing1.exe
LOADER: Extracting binaries
LOADER: Executing self as child
LOADER: set _MEIPASS2 to C:\Users\john\AppData\Local\Temp\_MEI30282
LOADER: Setting up to run child
LOADER: Creating child process
LOADER: Waiting for child process to finish...
PyInstaller Bootloader 3.x
LOADER: executable is C:\Users\john\Desktop\testing\dist\testing1.exe
LOADER: homepath is C:\Users\john\Desktop\testing\dist
LOADER: _MEIPASS2 is C:\Users\john\AppData\Local\Temp\_MEI30282
LOADER: archivename is C:\Users\john\Desktop\testing\dist\testing1.exe
LOADER: SetDllDirectory(C:\Users\john\AppData\Local\Temp\_MEI30282)
LOADER: Already in the child - running user's code.
LOADER: manifestpath: C:\Users\john\AppData\Local\Temp\_MEI30282\testing1.exe.ma
nifest
LOADER: Activation context created
LOADER: Activation context activated
LOADER: Python library: C:\Users\john\AppData\Local\Temp\_MEI30282\python35.dll
LOADER: Loaded functions from Python library.
LOADER: Manipulating environment (sys.path, sys.prefix)
LOADER: Pre-init sys.path is C:\Users\john\AppData\Local\Temp\_MEI30282\base_lib
rary.zip;C:\Users\john\AppData\Local\Temp\_MEI30282
LOADER: sys.prefix is C:\Users\john\AppData\Local\Temp\_MEI30282
LOADER: Setting runtime options
LOADER: Bootloader option: pyi-windows-manifest-filename testing1.exe.manifest
LOADER: Initializing python
LOADER: Overriding Python's sys.path
LOADER: Post-init sys.path is C:\Users\john\AppData\Local\Temp\_MEI30282\base_li
brary.zip;C:\Users\john\AppData\Local\Temp\_MEI30282
LOADER: Setting sys.argv
LOADER: setting sys._MEIPASS
LOADER: importing modules from CArchive
LOADER: extracted struct
LOADER: callfunction returned...
LOADER: extracted pyimod01_os_path
LOADER: callfunction returned...
LOADER: extracted pyimod02_archive
LOADER: callfunction returned...
LOADER: extracted pyimod03_importers
LOADER: callfunction returned...
LOADER: Installing PYZ archive with Python modules.
LOADER: PYZ archive: out00-PYZ.pyz
LOADER: Running pyiboot01_bootstrap.py
LOADER: Running pyi_rth_qt5.py
LOADER: Running pyi_rth_qt5plugins.py
Traceback (most recent call last):
  File "site-packages\PyInstaller\loader\rthooks\pyi_rth_qt5plugins.py", line 46
, in <module>
  File "c:\python35\lib\site-packages\PyInstaller\loader\pyimod03_importers.py",
 line 714, in load_module
    module = loader.load_module(fullname)
ImportError: DLL load failed: The specified module could not be found.
Failed to execute script pyi_rth_qt5plugins
LOADER: OK.
LOADER: Cleaning up Python interpreter.
LOADER: Back to parent (RC: -1)
LOADER: Doing cleanup
LOADER: Freeing archive status for C:\Users\john\Desktop\testing\dist\testing1.e
xe

我使用了 Window 7、python 3.5 PyQt5、pyinstaller 3.3.dev0+912586 或 pyinstaller 3.2.1(都尝试过)。当我尝试运行 dist 中的 exe 文件时。它显示“无法执行脚本 pyi_rth_qt5plugins”请帮忙。我尝试了谷歌上的方法,但仍然无法解决。有人解决吗?我已经被困在其中一周了。我应该改用较低版本的 python 和 PyQt4 吗?

最佳答案

此问题可能是由于 PyInstaller 未捆绑 QT DLL 导致的(请参阅 PyQT 5.7 DLLs are not bundled

使用“--paths”指令构建和运行示例代码工作正常,并且可以成功执行在“dist”文件夹中创建的应用程序:

pyinstaller --paths C:\Python35-32\Lib\site-packages\PyQt5\Qt\bin test.py

关于python-3.5 - ImportError: DLL 加载失败: 找不到指定的模块。无法执行脚本pyi_rth_qt5plugins,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42880859/

相关文章:

jupyter-notebook - 如何为 jupyter notebook 设置 PYTHONHASHSEED?

python - 如何更换窗口TKInter

python - Qt 按钮样式从 ui 预览到原始窗口各不相同

python-3.x - RadioBox 信号困惑

python - 为单个标签赋予颜色会消耗过多的处理能力

python - 如何在 Windows 上使用 PyInstaller 创建 Linux 和 MacOS 可执行文件?

python - 如何让 ipython RichIPythonWidget 在 pyinstaller 环境中使用 pyside?

Python 根本无法工作

python - pyinstaller:更改应用程序图标

python - 当 te coro 在 sleep 超时之前完成时,如何清理 coro 中的 asyncio.sleep()