Hey Guys,
I was working on this stuff today and came across several issues that many of you have encountered. Thanks to the community for providing solutions. Here to lend some helping hands and share what I’ve learned to help resolve these common problems.
Version Update for Altair/Vega-Lite :
- For the new version of Altair/Vega-Lite, update the reference to use
v5
instead ofv4
.
Error with Magic Functions & Import Issues :
- When using Streamlit with PyInstaller, you might encounter errors with magic functions and importing modules.
- This is because only Streamlit metadata is loaded, not the entire package. This issue is noted by
charles
,hmas
,kevin
, andnikhil
. - Solution: Modify
hook-streamlit.py
as follows:
from PyInstaller.utils.hooks import copy_metadata, collect_submodules
datas = copy_metadata('streamlit')
hiddenimports = collect_submodules('streamlit')
PyArrow Issue for @Steve_Liu
- PyArrow Error:
- The use of
pyarrow
with PyInstaller’s public hook can lead to errors. - Solution: Create a new file named
hook-pyarrow.py
in the hooks directory with the following code:
- The use of
from PyInstaller.utils.hooks import collect_submodules, collect_data_files
hiddenimports = collect_submodules('pyarrow')
datas = collect_data_files('pyarrow', include_py_files=True)
Dkdatascientist
- Custom Hook Recommendation:
- It’s advised to use a custom hook instead of PyInstaller’s default for specific packages for your case
- FYI: If PyInstaller has a public hook for a package, it will use it; otherwise, it will fall back to a custom hook.
for yuchang_zhu ,
- Adding Hidden Imports:
- To include necessary imports for Streamlit, add the following to your
.spec
file:
- To include necessary imports for Streamlit, add the following to your
hiddenimports=['streamlit', 'wget']
Finally Streamlit Hook for @mohamed_zekkiriya ,
- Streamlit Hook Setup:
- As discussed by
hmasdev
and for clarity to@mohamed_zekkiriya
, set up your working directory as follows:
- As discussed by
WORKINGDIR/
- hooks/hook-streamlit.py
- main.py
- run_main.py
In hook-streamlit.py
, use this code:
from PyInstaller.utils.hooks import copy_metadata, collect_submodules
datas = copy_metadata('streamlit')
hiddenimports = collect_submodules('streamlit')
Cheers lads (Wish everyone could get notified , Since I am new user I can only tag two people )