[Note This still doesn’t work]
I created an example project like so:
streamlit-build-test/
- env.yml
- examply.py
- hook-streamlit.py
- streamlit_run.py
The env.yml
is for the conda environment: [I also checked with a virtualenv environment, and had the exact same problem]
name: streamlit-build-test
channels:
- defaults
dependencies:
- python=3.6
- pip
- pip:
- streamlit
example.py
is:
import streamlit as st
if __name__ == '__main__':
x = st.text('foo')
Pyinstaller couldn’t find streamlit on its own, so I had to add hook-streamlit.py
:
from PyInstaller.utils.hooks import copy_metadata
datas = copy_metadata('streamlit')
And then streamlit_run.py
is a wrapper for the app, that essentially calls streamlit run example.py
:
import sys
import streamlit.cli as stcli
if __name__ == '__main__':
sys.argv = ["streamlit", "run", "example.py", "--global.developmentMode=false"]
sys.exit(stcli.main())
Now, to compile the app, run:
$ pyinstaller --onefile --additional-hooks-dir=. -w streamlit_run.py
Then run the compiled app with:
$ dist/streamlit_run
The command line shows streamlit is running, but unfortunately the browser can’t seem to find the page (at the ip) on localhost, and gives a 404 not found
error.