【问题标题】:pyinstaller and onefile build causes Error loading Python DLL (error code 14001)pyinstaller 和 onefile 构建导致加载 Python DLL 时出错(错误代码 14001)
【发布时间】:2015-12-04 02:40:47
【问题描述】:

我使用 pyinstaller 从我的脚本文件中创建一个 exe。我的脚本是 mysql_backup.py

我跑

pyinstaller --onefile mysql_backup.py

输出

52 INFO: wrote
C:\Users\vlahopou\PycharmProjects\TestClient\mysql_backup.spec
73 INFO: Testing for ability to set icons, version resources...
104 INFO: ... resource update available
105 INFO: UPX is not available.
128 INFO: Processing hook hook-os
219 INFO: Processing hook hook-time
223 INFO: Processing hook hook-cPickle
276 INFO: Processing hook hook-_sre
368 INFO: Processing hook hook-cStringIO
446 INFO: Processing hook hook-encodings
457 INFO: Processing hook hook-codecs
831 INFO: Extending PYTHONPATH with C:\Users\vlahopou\PycharmProjects\TestClient
831 INFO: checking Analysis
832 INFO: building Analysis because out00-Analysis.toc non existent
832 INFO: running Analysis out00-Analysis.toc
832 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
902 INFO: Searching for assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
902 WARNING: Assembly not found
902 ERROR: Assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found
996 INFO: Searching for assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
996 WARNING: Assembly not found
996 ERROR: Assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found
1075 INFO: Analyzing C:\Python27\lib\site-packages\PyInstaller\loader\_pyi_bootstrap.py
1088 INFO: Processing hook hook-os
1101 INFO: Processing hook hook-site
1117 INFO: Processing hook hook-encodings
1213 INFO: Processing hook hook-time
1217 INFO: Processing hook hook-cPickle
1270 INFO: Processing hook hook-_sre
1375 INFO: Processing hook hook-cStringIO
1470 INFO: Processing hook hook-codecs
1900 INFO: Processing hook hook-pydoc
2013 INFO: Processing hook hook-email
2056 INFO: Processing hook hook-httplib
2092 INFO: Processing hook hook-email.message
2148 INFO: Analyzing C:\Python27\lib\site-packages\PyInstaller\loader\pyi_importers.py
2181 INFO: Analyzing C:\Python27\lib\site-packages\PyInstaller\loader\pyi_archive.py
2210 INFO: Analyzing C:\Python27\lib\site-packages\PyInstaller\loader\pyi_carchive.py
2242 INFO: Analyzing C:\Python27\lib\site-packages\PyInstaller\loader\pyi_os_path.py
2246 INFO: Analyzing mysql_backup.py
2328 INFO: Processing hook hook-xml
2427 INFO: Processing hook hook-xml.sax
2471 INFO: Processing hook hook-pyexpat
2474 INFO: Hidden import 'codecs' has been found otherwise
2474 INFO: Hidden import 'encodings' has been found otherwise
2474 INFO: Looking for run-time hooks
2746 INFO: Using Python library C:\WINDOWS\system32\python27.dll
2846 INFO: Warnings written to C:\Users\vlahopou\PycharmProjects\TestClient\build\mysql_backup\warnmysql_backup.txt
2858 INFO: checking PYZ
2858 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
2858 INFO: building PYZ (ZlibArchive) out00-PYZ.toc
3756 INFO: checking PKG
3756 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
3757 INFO: building PKG (CArchive) out00-PKG.pkg
5257 INFO: checking EXE
5259 INFO: rebuilding out00-EXE.toc because mysql_backup.exe missing
5259 INFO: building EXE from out00-EXE.toc
5262 INFO: Appending archive to EXE C:\Users\vlahopou\PycharmProjects\TestClient\dist\mysql_backup.exe

当我尝试在未安装 python 的机器上执行此操作时,问题就出现了。我希望能够提取一个捆绑了 python 的 exe,这样当用户想要运行它时它就没有任何依赖关系。 pyinstaller可以吗?我的文件在生成它的机器上正常运行。

调试信息

C:\>mysql_backup.exe
LOADER: executable is C:\mysql_backup.exe
LOADER: homepath is C:
LOADER: _MEIPASS2 is NULL
LOADER: archivename is C:\mysql_backup.exe
LOADER: Extracting binaries
LOADER: Executing self as child
LOADER: Setting up to run child
LOADER: Creating child process
LOADER: Waiting for child process to finish...
LOADER: executable is C:\mysql_backup.exe
LOADER: homepath is C:
LOADER: _MEIPASS2 is C:\Users\ADMINI~1\AppData\Local\Temp\2\_MEI21882
LOADER: archivename is C:\mysql_backup.exe
LOADER: Already in the child - running user's code.
LOADER: manifestpath: C:\Users\ADMINI~1\AppData\Local\Temp\2\_MEI21882\mysql_backup.exe.manifest
LOADER: Error activating the context
LOADER: Python library: C:\Users\ADMINI~1\AppData\Local\Temp\2\_MEI21882\python27.dll
Error loading Python DLL: C:\Users\ADMINI~1\AppData\Local\Temp\2\_MEI21882\python27.dll (error code 14001)
LOADER: Deactivating activation context
LOADER: Releasing activation context
LOADER: Done
LOADER: Back to parent
LOADER: Doing cleanup
LOADER: Freeing archive status for C:\mysql_backup.exe

【问题讨论】:

  • 听起来好像没有安装该 python 版本的 VC 运行时。你有它,因为你已经安装了 python。
  • 你能详细说明一下吗?另外忘了提到我正在尝试在 win server 2008 的 vm 上运行我的 exe,而 pyinstaller 在 win7 机器上执行。
  • 我已经使用了 py2exe,还没有使用 pyinstaller(但我需要)。 python需要VC运行时DLL才能运行;附加的清单应该告诉它要加载哪个运行时。您可以尝试在目标机器上安装它以验证这是您的问题:microsoft.com/download/en/details.aspx?displaylang=en&id=29
  • 但 pyinstaller 应该将其附加到文件中。此行之后的错误:INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable - 暗示它没有找到它,所以它没有进入你的文件。不幸的是,这就是我所能提供的帮助 - 不知道为什么 pyinstaller 不包括它。
  • 在没有安装 python 没有 vm 的环境中测试它并且工作(没有 python 在他的路径上没有 python 在 c:)...它也适用于我的电脑,但我想这是因为我安装了python

标签: python windows pyinstaller


【解决方案1】:

我在部署可执行文件时遇到了类似的问题,错误代码 14001 完全相同,我用这组参数解决了它:

pyinstaller --clean --win-private-assemblies -F <python files>

来自帮助说明:

--clean             Clean PyInstaller cache and remove temporary files
                    before building.

--win-private-assemblies
                    Any Shared Assemblies bundled into the application
                    will be changed into Private Assemblies. This means
                    the exact versions of these assemblies will always be
                    used, and any newer versions installed on user
                    machines at the system level will be ignored.

-F, --onefile       Create a one-file bundled executable.

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2012-01-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-12-13
  • 2014-10-01
  • 1970-01-01
  • 2022-11-28
相关资源
最近更新 更多