How to package psutil with py2exe?

帅比萌擦擦* 提交于 2019-12-22 11:08:00

问题


The app is working fine on my development win8 environment, but when it is packaged with py2exe and run on the production machine it throw the exception:

"The procedure entry point RtlIdnToAscii could not be located in the dynamic link library ntdll.dll"

The detail content of the log file is

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.

It seems that a dll required by psutil is missing during the package process. I have tried to add the py2exe options with

py2exe_options = {"py2exe":{"includes":['decimal', '_mssql', 'uuid', 'psutil', '_psutil_mswindows']}}

But it is not working. Any ideas? Thanks in advance!


回答1:


The solution is to remove System DLLs from the project directory. When I added psutil to my application py2exe added a lot of system DLLs to my project. It worked correctly on my and some other computers, but failed on another one. Removing from the project the .dll files that were available in C:\Windows\System32 solved the issue.

Finally in my case the solution was to add:

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

into the py2exe options in setup.py file.



来源:https://stackoverflow.com/questions/19487306/how-to-package-psutil-with-py2exe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!