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.
It looks like you're building your EXE without including the font files from
pyfiglet. This is because PyInstaller cannot interpret thepkg_resourcescall from insidepyfigletwhen building the set of files to package up.I've not used it myself, but it looks like you might be able to add the font files to your package by updating your spec file to include all the missing files. However, you should pay attention to the FAQ, which says that there is only limited support for
pkg_resources(and so it may be that you simply cannot packagepyfiglet).