请阅读所有这篇文章并帮助我。
我想创造--onefile
可以使用 pyinstaller 执行。
我在开发方面有这些:
- 视窗 8.1 x64
- Qt 5.2.1
- 蟒蛇27
- PyQt5.2.1(使用 Visual Studio 2012 构建)
- 视觉工作室2012
- py安装程序2.1
- pyWin32
这些在部署端(VirtualBox)(作为干净的虚拟机):
- 视窗 8 x64
- vcredist_x64 2012
这是我想要构建的简单 python 程序:
#main.py
import sys
from PyQt5.QtWidgets import QApplication, QPushButton
app = QApplication(sys.argv)
win = QPushButton("Hello World!")
win.show()
sys.exit(app.exec_())
#------------------------------------------------
好的,当我将其构建为--onedir
(pyinstaller main.py
)它在开发端和部署端工作得很好。
当我将其构建为--onefile
(pyinstaller -F main.py
)它在开发方面工作正常,但在部署方面不起作用。
并给出这个错误:
该应用程序无法启动,因为它无法找到或加载
Qt 平台插件“windows”。
可用的平台插件有:minimal、offscreen、windows。
重新安装应用程序可能会解决此问题。
我有什么错?或者这栋楼有什么问题?
就这个错误而言,它找不到qt5_plugins
文件夹位于_MEIxxxxx
临时文件夹中的文件夹。
或者,你认为问题是来自sys
模块?如果是,我该怎么办?
感谢您的提前回复
Update:
我应该说我在构建时有这个警告和错误:
第1024章 警告:没有这样的文件 C:\Python27\msvcp90.dll 1024 警告:
装配不完整 1026 错误:装配
amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none 未找到
update2:
i added msvcp90.dll
, msvcm90.dll
to c:\Python27
手动,这个警告和错误就解决了。
更新3:
qt.conf:
[Paths]
Plugins = qt5_plugins
主要规格:
# -*- mode: python -*-
a = Analysis(['main.py'],
pathex=['D:\\hello2'],
hiddenimports=['sip', "PyQt5.QtCore", "PyQt5.QtGui", "PyQt5.QtWidgets"],
hookspath=None,
runtime_hooks=None)
pyz = PYZ(a.pure)
plugins = [("qt5_plugins/platforms/qwindows.dll",
"C:\\Qt\\Qt5.2.1\\5.2.1\\msvc2012_64\\plugins\\platforms\\qwindows.dll", "BINARY")]
data = [
("qt.conf", "qt.conf", "DATA")
]
exe = EXE(
pyz,
a.scripts,
a.binaries + plugins,
a.zipfiles,
a.datas + data,
name='main.exe',
debug=False,
strip=None,
upx=True,
console=True
)
qt5_plugins
自动创建的pyinstaller
有平台插件。我认为它不需要手动添加为额外库。