我试图使用py2exe(0.9.2.0)将python脚本转换为可执行文件。
我到目前为止失败了因为py2exe找不到模块Qt:
C:\Users\Tobias\eclipse\workspace\pydevTest>python setup.py py2exe
running py2exe
5 missing Modules
------------------
? Qt imported from __SCRIPT__
? WizardPage imported from __SCRIPT__
? readline imported from cmd, code, pdb
? win32api imported from platform
? win32con imported from platform
Building 'dist\Test.exe'.
Building shared code archive 'dist\library.zip'.
Copy c:\windows\system32\python34.dll to dist
Copy C:\Python34\DLLs\_hashlib.pyd to dist\_hashlib.pyd
Copy C:\Python34\lib\site-packages\PyQt5\QtGui.pyd to dist\PyQt5.QtGui.pyd
Copy C:\Python34\lib\site-packages\PyQt5\QtCore.pyd to dist\PyQt5.QtCore.pyd
Copy C:\Python34\DLLs\unicodedata.pyd to dist\unicodedata.pyd
Copy C:\Python34\DLLs\_ssl.pyd to dist\_ssl.pyd
Copy C:\Python34\DLLs\_elementtree.pyd to dist\_elementtree.pyd
Copy C:\Python34\DLLs\select.pyd to dist\select.pyd
Copy C:\Python34\lib\site-packages\sip.pyd to dist\sip.pyd
Copy C:\Python34\lib\site-packages\PyQt5\QtWidgets.pyd to dist\PyQt5.QtWidgets.pyd
Copy C:\Python34\DLLs\pyexpat.pyd to dist\pyexpat.pyd
Copy C:\Python34\DLLs\_lzma.pyd to dist\_lzma.pyd
Copy C:\Python34\DLLs\_socket.pyd to dist\_socket.pyd
Copy C:\Python34\DLLs\_bz2.pyd to dist\_bz2.pyd
Copy C:\Python34\DLLs\_ctypes.pyd to dist\_ctypes.pyd
Copy DLL C:\Python34\lib\site-packages\PyQt5\Qt5Core.dll to dist\
Copy DLL C:\Python34\lib\site-packages\PyQt5\icudt53.dll to dist\
Copy DLL C:\Python34\lib\site-packages\PyQt5\icuuc53.dll to dist\
Copy DLL C:\Python34\lib\site-packages\PyQt5\icuin53.dll to dist\
Copy DLL C:\Python34\lib\site-packages\PyQt5\Qt5Gui.dll to dist\
Copy DLL C:\Python34\lib\site-packages\PyQt5\Qt5Widgets.dll to dist\
我的setup.py看起来如下:
import py2exe
from distutils.core import setup
setup(windows=["./src/Test.py"], options={"py2exe" : {"includes" : ["sip", "PyQt5.QtGui","PyQt5.QtWidgets","PyQt5.QtCore","PyQt5.QtCore"]}})
脚本相当简单。摆脱第一个错误后,我可能还会帮助其他四个缺失的模块...
非常感谢!
答案 0 :(得分:0)
您需要添加以下dll:
像这样的事情:C:\ Windows \ System32下\ msvcp100.dll
C:\ Windows \ System32下\ msvcr100.dll
C:\ Python34 \ LIB \站点包\ PyQt4的\插件\平台\ qwindows.dll
data_files = (
('', glob(r'C:\Windows\SYSTEM32\msvcp100.dll')),
('', glob(r'C:\Windows\SYSTEM32\msvcr100.dll')),
('platforms', glob(r'C:\Python34\Lib\site-packages\PyQt4\plugins\platforms\qwindows.dll')),
),
答案 1 :(得分:0)
抱歉,先前的答案对我不起作用:https://stackoverflow.com/a/37622355/7426109
(我有不同的版本)
另一方面,将其添加到您的路径中是:“ C:\ Program Files(x86)\ Python38-32 \ Lib \ site-packages \ PyQt5 \ Qt \ bin “。
将“ Qt”(“ C:\ Program Files(x86)\ Python38-32 \ Lib \ site-packages \ PyQt5 \ Qt ”)文件夹复制到“ dist”,然后使用批处理脚本,将“ .dist \ Qt \ bin ”添加到当前CMD窗口中的PATH。 (当然,这并不完美,但是至少可以在另一台机器上执行)
Windows 10 x64,Python 3.8.6 x32,PyQt5 == 5.15.1,py2exe == 0.10.0.2