Can not run .exe packed by pyinstaller

老子叫甜甜 提交于 2021-02-11 13:12:58

问题


My source code

I am using pyfiglet in my project and when compiling the .exe it returns

Traceback (most recent call last):
  File "pkg_resources\__init__.py", line 358, in get_provider
KeyError: 'pyfiglet.fonts'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "Dragon_Game.py", line 5, in <module>
  File "pyfiglet\__init__.py", line 65, in figlet_format
  File "pyfiglet\__init__.py", line 820, in __init__
  File "pyfiglet\__init__.py", line 827, in setFont
  File "pyfiglet\__init__.py", line 126, in __init__
  File "pyfiglet\__init__.py", line 139, in preloadFont
  File "pkg_resources\__init__.py", line 1133, in resource_exists
  File "pkg_resources\__init__.py", line 360, in get_provider
ModuleNotFoundError: No module named 'pyfiglet.fonts'

I can't seem to figure out why it won't work, the .py and .pyc files work fine.


回答1:


You should probably add pyfiglet to your data list in your spec file. You can do this yourself, by editing the spec file. Otherwise, you could build with something like

pyinstaller --add-data "venv\Lib\site-packages\pyfiglet;./pyfiglet" Dragon_Game.py

Where the path leads to the pyfiglet file inside your PC/environment.

See this question.



来源:https://stackoverflow.com/questions/64582795/can-not-run-exe-packed-by-pyinstaller

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