pyinstaller 打包报错问题大全

pyinstaller 打包exe运行错误 No module named 'pkg_resources.py2_warn'

背景:

使用pyinstaller打包好exe后,运行出现以下错误。在更新pip的python库前打包是可以正常运行的。

打包过程没有出现任何错误提示。环境python3.7.4 win64

Traceback (most recent call last):
  File "site-packages\PyInstaller\loader\rthooks\pyi_rth_pkgres.py", line 13, in
 
  File "c:\program files\python37\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\pkg_resources\__init__.py", line 86, in 
ModuleNotFoundError: No module named 'pkg_resources.py2_warn'
[3844] Failed to execute script pyi_rth_pkgres

解决方法:

我的方法是:找到 \Python37\Lib\site-packages\pkg_resources\__init__.py,把86行 注释掉。重新打包即可。

__import__('pkg_resources.extern.packaging.version')
__import__('pkg_resources.extern.packaging.specifi

你可能感兴趣的:(pyinstaller)