如何用py2exe打包psutil?

2024-03-09

该应用程序在我的开发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.

看来需要一个dllpsutil http://code.google.com/p/psutil/打包过程中丢失。我尝试添加 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 选项。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何用py2exe打包psutil? 的相关文章

随机推荐