该应用程序在我的开发 win8 环境中运行良好,但是当它与 py2exe 打包并在生产机器上运行时,它抛出异常:

“无法在动态链接库 ntdll.dll 中找到过程入口点 RtlIdnToAscii”

日志文件的详细内容是

Traceback (most recent call last):
  File "DataviewerBackupRestorer.py", line 6, in <module>
  File "RestorController.pyc", line 7, in <module>
  File "psutil\__init__.pyc", line 136, in <module>
  File "psutil\_psmswindows.pyc", line 14, in <module>
  File "_psutil_mswindows.pyc", line 12, in <module>
  File "_psutil_mswindows.pyc", line 10, in __load
ImportError: DLL load failed: The specified procedure could not be found.

好像是打包过程中缺少psutil需要的dll。我试图添加 py2exe 选项
py2exe_options = {"py2exe":{"includes":['decimal', '_mssql', 'uuid', 'psutil', '_psutil_mswindows']}}

但它不起作用。有任何想法吗?提前致谢!

最佳答案

解决方案是从项目目录中删除系统 DLL。当我将 psutil 添加到我的应用程序 py2exe 时,我的项目中添加了很多系统 DLL。它在我和其他一些计算机上正常工作,但在另一台计算机上失败。从项目中删除 C:\Windows\System32 中可用的 .dll 文件解决了该问题。

最后在我的情况下,解决方案是添加:

            'dll_excludes': [ "IPHLPAPI.DLL", "NSI.dll",  "WINNSI.DLL",  "WTSAPI32.dll"]

进入 setup.py 文件中的 py2exe 选项。

关于python - 如何使用 py2exe 打包 psutil?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19487306/

10-14 03:00