I'm attempting to use PyInstaller to compile one of the demo scripts for Asciimatics, in hopes to eventually be able to create a simple GUI for a text-based game I'm developing, and it returns the following error:
C:\Users\X\Documents\Python Scripts\asciimatics samples\dist\test>test.exe
Traceback (most recent call last):
File "site-packages\setuptools-19.2-py3.4.egg\pkg_resources\__init__.py", line 443, in get_provider
KeyError: 'pyfiglet.fonts'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 22, in <module>
File "site-packages\asciimatics\screen.py", line 859, in wrapper
File "<string>", line 12, in demo
File "site-packages\asciimatics\renderers.py", line 276, in __init__
File "site-packages\pyfiglet\__init__.py", line 710, in __init__
File "site-packages\pyfiglet\__init__.py", line 717, in setFont
File "site-packages\pyfiglet\__init__.py", line 90, in __init__
File "site-packages\pyfiglet\__init__.py", line 100, in preloadFont
File "site-packages\setuptools-19.2-py3.4.egg\pkg_resources\__init__.py", line 1160, in resource_exists
File "site-packages\setuptools-19.2-py3.4.egg\pkg_resources\__init__.py", line 445, in get_provider
ImportError: No module named 'pyfiglet.fonts'
test returned -1
Googling this error returned this thread, but it seems to me that the error is caused by a fault within SublimeFiglet itself, and was fixed two years ago.
I'm using Python 3.4 on Windows 10. I had to downgrade setuptools to 19.2 (I believe is the version I had to downgrade to) because I was getting an error stating that the packaging package was missing when attempting to run the compiled .exe file.
I've imported both the six (due to it being a hidden import) and pyfiglet modules in test.py, in addition to the other imports necessary to run the script. Importing pyfiglet and any variations I can think of changes nothing. I could change the spec file to add a hidden import for six, though I don't see how that would change anything.
Here is the spec file Pyinstaller uses:
block_cipher = None
a = Analysis(['test.py'],
pathex=['C:\\Users\\Sirindil\\Documents\\Python Scripts\\asciimatics samples'],
binaries=None,
datas=None,
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='test',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='test')
Every sample script included with Asciimatics returns this same error for me. I've tried using different options when running pyinstaller on the script, with no success. Am I missing something? I have no idea how to fix this.
I was also facing the same issue and i have imported the pyfiglet folder inside in exe and it works for me. I'm having venv folder as a virtual environment but in case you are having different virtual environment folder name then change the folder name as well, otherwise only change the AppName.py.
pyinstaller --add-data "venv\Lib\site-packages\pyfiglet;./pyfiglet" AppName.py