使用pyinstaller创建可执行文件时出错
Error when creating executable file with pyinstaller
我正在尝试使用 pyinstaller 为我的 python 脚本创建一个 exe,每次它遇到可以在 pastebin here 中找到的错误。
此外,当我双击 exe 文件时,它显示此错误:
C:Users\Afro\AppData\Local\Temp_MEI51322\VCRUNTIME140.dll is either not designed to run on windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vendor for support. Error status 0xc000007b
然后是这个:
Error loading Python DLL:
C:\Users\Afro\AppData\Local\Temp_MEI51322\python35.dll(error code 193)
请问有什么问题吗?
我也被类似的问题困扰着。在您的情况下,可能是 UPX 正在中断 vcruntime140.dll。
解决方案是关闭 UPX,因此只需将 --noupx 添加到您的 pyinstaller 调用中即可。
pyinstaller --noupx --onedir --onefile --windowed get.py
在我的例子中是:
pyinstaller --clean --win-private-assemblies --noupx --onedir --onefile script.py
--windowed导致wxWidgets出现问题
我也遇到过这个问题,根本原因是我用upx来压缩文件大小。解决方案是排除不应该被upx压缩的文件:
pyinstaller --onefile --console --upx-dir=/path/to/upx --upx-exclude=vcruntime140.dll --upx-exclude=python36.dll my_script.py
我尝试使用此版本的 Pyinstaller 命令,将此命令添加到 .bat
文件并执行 .bat
文件。它对我有用:
pyinstaller --log-level=WARN ^
--upx-dir <PATH_TO_UPX.exe_FILE> ^
--upx-exclude vcruntime140.dll ^
--upx-exclude ucrtbase.dll ^
--upx-exclude qwindows.dll ^
--upx-exclude libegl.dll ^
--name <NAME_OF_APPLICATION> ^
--onefile --windowed ^
<PY_DEPENDENT_FILES.py>
我正在尝试使用 pyinstaller 为我的 python 脚本创建一个 exe,每次它遇到可以在 pastebin here 中找到的错误。
此外,当我双击 exe 文件时,它显示此错误:
C:Users\Afro\AppData\Local\Temp_MEI51322\VCRUNTIME140.dll is either not designed to run on windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vendor for support. Error status 0xc000007b
然后是这个:
Error loading Python DLL: C:\Users\Afro\AppData\Local\Temp_MEI51322\python35.dll(error code 193)
请问有什么问题吗?
我也被类似的问题困扰着。在您的情况下,可能是 UPX 正在中断 vcruntime140.dll。 解决方案是关闭 UPX,因此只需将 --noupx 添加到您的 pyinstaller 调用中即可。
pyinstaller --noupx --onedir --onefile --windowed get.py
在我的例子中是:
pyinstaller --clean --win-private-assemblies --noupx --onedir --onefile script.py
--windowed导致wxWidgets出现问题
我也遇到过这个问题,根本原因是我用upx来压缩文件大小。解决方案是排除不应该被upx压缩的文件:
pyinstaller --onefile --console --upx-dir=/path/to/upx --upx-exclude=vcruntime140.dll --upx-exclude=python36.dll my_script.py
我尝试使用此版本的 Pyinstaller 命令,将此命令添加到 .bat
文件并执行 .bat
文件。它对我有用:
pyinstaller --log-level=WARN ^
--upx-dir <PATH_TO_UPX.exe_FILE> ^
--upx-exclude vcruntime140.dll ^
--upx-exclude ucrtbase.dll ^
--upx-exclude qwindows.dll ^
--upx-exclude libegl.dll ^
--name <NAME_OF_APPLICATION> ^
--onefile --windowed ^
<PY_DEPENDENT_FILES.py>