python package can not run with pyinstaller, tips ModuleNotFoundError: No module named 'pkg_resources.py2_warn' final solution useful

At first I even the most basic procedures such as

print(‘hello’)

After the package does not allow normal operation, suggesting that warn ***. Txt file is not found in a lot of modules.
Tip After running:
ModuleNotFoundError: No Module named 'pkg_resources.py2_warn'
[17404] Failed to the Execute Script pyi_rth_pkgres

Traceback (most recent call last):
  File "site-packages\PyInstaller\loader\rthooks\pyi_rth_pkgres.py", line 13, in <module>
  File "c:\users\liu\appdata\local\programs\python\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 <module>
ModuleNotFoundError: No module named 'pkg_resources.py2_warn'
[17404] Failed to execute script pyi_rth_pkgres

The Internet to find a lot of ways will not work, and finally saw this article principles and solutions
ultimate solution is to modify the files in this directory

C:\Users\***\AppData\Local\Programs\Python\Python37\Lib\site-packages\pkg_resources\ init.py

Comment row after opening the 86th, after saving, can be repackaged.

82 import(‘pkg_resources.extern.packaging.version’)
83 import(‘pkg_resources.extern.packaging.specifiers’)
84 import(‘pkg_resources.extern.packaging.requirements’)
85 import(‘pkg_resources.extern.packaging.markers’)
86 # import(‘pkg_resources.py2_warn’)
metaclass = type

Specific reasons can be found in: https://blog.csdn.net/fred110119/article/details/104667749

Engage in a long time finally good! ! !

Released five original articles · won praise 8 · views 1677

Guess you like

Origin blog.csdn.net/qq_40608730/article/details/104864943