Reputation: 31
I made a streamlit application to act as a front end for a forecasting program and then I created a pyinstaller executable file to run the application. The problem rises when I run the executable file, I get the following error: pkg_resources.DistributionNotFound: The 'streamlit' distribution was not found and is required by the application
with this traceback:
Traceback (most recent call last):
File "main.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "/opt/anaconda3/envs/Python35/lib/python3.5/site-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "site-packages/streamlit/__init__.py", line 75, in <module>
File "site-packages/pkg_resources/__init__.py", line 476, in get_distribution
File "site-packages/pkg_resources/__init__.py", line 352, in get_provider
File "site-packages/pkg_resources/__init__.py", line 895, in require
File "site-packages/pkg_resources/__init__.py", line 781, in resolve
pkg_resources.DistributionNotFound: The 'streamlit' distribution was not found and is required by the application
[48095] Failed to execute script main
The file was created with the following command: pyinstaller --onefile -w main.py
This was setup on macOS Catalina with python 3.5.6 within a Conda environment
If there are any details that I may have missed that would help with this, please let me know.
Upvotes: 3
Views: 2761
Reputation: 1730
Looks like you need to add a hook
file called hook-streamlit.py
with the following contents
from PyInstaller.utils.hooks import copy_metadata
datas = copy_metadata('streamlit')
You also need to pass the --additional-hooks-dir
flag to your pyinstaller
command.
If you've placed the hook file in the same directory as your python script you can specify it like so
pyinstaller --onefile --additional-hooks-dir=. -w main.py
Upvotes: 2