无法运行pyinstaller打包的.exe

时间:2020-10-28 23:27:42

标签: python python-3.x pyinstaller

My source code

我在项目中使用pyfiglet,并且在编译.exe时返回

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'

我似乎无法弄清楚为什么它不起作用,.py和.pyc文件可以正常工作。

1 个答案:

答案 0 :(得分:1)

您可能应该将pyfiglet添加到spec文件中的数据列表中。您可以自己编辑编辑规范文件。否则,您可以使用类似的东西

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

该路径指向PC /环境中的pyfiglet文件。

请参见this question