##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文件时。它显示&#34;无法执行脚本pyi_rth_qt5plugins&#34;请帮忙。我在谷歌上尝试这种方法,但我仍然无法解决它。有人解决了吗?我被困了一个星期。我应该改为更低版本的python和PyQt4吗?
答案 0 :(得分:1)
此问题可能是由PyInstaller未捆绑QT DLL引起的(请参阅PyQT 5.7 DLLs are not bundled。
使用&#34; - 路径&#34;构建和运行示例代码指令工作正常,应用程序在&#34; dist&#34;文件夹可以成功执行:
pyinstaller --paths C:\Python35-32\Lib\site-packages\PyQt5\Qt\bin test.py
答案 1 :(得分:0)
为C:\ Python35-32 \ Lib \ site-packages \ PyQt5 \ Qt \ bin设置环境