Using PyInstaller (or similar) to create an executable

try copypasting the st_on_hover_tabs folder to place where .exe is created.

Hello everyone,

So I tried this method for the executable but I encountered a problem when I want to launch the executable. When I just the terminal to launch it I have no problem it launch [on server.port 8501] but when I double click on it, it deployed on server port 3000 telling me:

2023-05-12 18:12:39.928 DEBUG   streamlit.web.server.server: Starting server...
2023-05-12 18:12:39.929 DEBUG   streamlit.web.server.server: Serving static content from the Node dev server
2023-05-12 18:12:39.937 DEBUG   streamlit.web.server.server: Server started on port 8501
2023-05-12 18:12:39.938 DEBUG   streamlit.runtime.runtime: Runtime state: RuntimeState.INITIAL -> RuntimeState.NO_SESSIONS_CONNECTED
2023-05-12 18:12:40.212 DEBUG   git.cmd: Popen(['git', 'version'], cwd=/Users/c.bajan, universal_newlines=False, shell=None, istream=None)
2023-05-12 18:12:40.250 DEBUG   git.cmd: Popen(['git', 'version'], cwd=/Users/c.bajan, universal_newlines=False, shell=None, istream=None)

I even check with: lsof -ti tcp:8501 | xargs kill to be sure to have nothing on this port but no change.
Does someone else encountered this issue and tell me what to do?

@charlesmyu Thanks a lot it works like a charm with streamlit 1.22 and pyinstaller 5.10 .
@littletuna Thanks too for the import, that’s indeed an odd behaviour.

But do you have a problem with session.state ? since the app is first read in python and not with streamlit, we can get this error:

2023-05-23 09:26:43.640 WARNING streamlit.runtime.state.session_state_proxy: Session state does not function when running a script without `streamlit run`

Any work around this ? Execept using Global variables ?

I just replied to post on Stack Exchange about bundling a Streamlit app into an executable. I know this feature request is linked way, way up in this topic, but I feel like it’s very underrated given how often I see this issue.

Anyone who wants Streamlit to be easier to package into a self-contained executable, please vote on this feature request so the devs can track its popularity.

Feel free to comment about your use case/scenario that makes it a desirable feature for you over some local server deployment. If the devs know people want it (and why they want it) that will increase the likelihood of it getting attention. :grin:

1 Like

@charlesmyu thanks for the info, it really saved so much time for the newer versions of streamlit

However, I’m getting problems with streamlit 1.22, pyinstaller 5.11. If my app doesn’t use st.table, I’m fine, but if I use st.table, I’m stuck.

It works when run with python, but when I run pyinstaller, it complains of missing hidden import “pyarrow.compat”. which is fine until I use st.table, at which point it throws exception:

Traceback (most recent call last):
  File "pyarrow\pandas-shim.pxi", line 100, in pyarrow.lib._PandasAPIShim._check_import
  File "pyarrow\pandas-shim.pxi", line 56, in pyarrow.lib._PandasAPIShim._import_pandas
ModuleNotFoundError: No module named 'pyarrow.vendored.version'
Exception ignored in: 'pyarrow.lib._PandasAPIShim._have_pandas_internal'
Traceback (most recent call last):
  File "pyarrow\pandas-shim.pxi", line 100, in pyarrow.lib._PandasAPIShim._check_import
  File "pyarrow\pandas-shim.pxi", line 56, in pyarrow.lib._PandasAPIShim._import_pandas
ModuleNotFoundError: No module named 'pyarrow.vendored.version'
2023-05-30 14:06:54.031 Uncaught app exception
Traceback (most recent call last):
  File "streamlit\runtime\scriptrunner\script_runner.py", line 565, in _run_script
  File "C:\_JIRA\Transcriber\dist\Transcribe.py", line 89, in <module>
    st.table(setData)
  File "streamlit\runtime\metrics_util.py", line 332, in wrapped_func
  File "streamlit\elements\dataframe_selector.py", line 156, in table
  File "streamlit\runtime\metrics_util.py", line 332, in wrapped_func
  File "streamlit\elements\arrow.py", line 159, in _arrow_table
  File "streamlit\elements\arrow.py", line 197, in marshall
  File "streamlit\type_util.py", line 757, in data_frame_to_bytes
  File "pyarrow\table.pxi", line 3681, in pyarrow.lib.Table.from_pandas
  File "pyarrow\pandas_compat.py", line 570, in dataframe_to_arrays
  File "pyarrow\pandas_compat.py", line 385, in _get_columns_to_convert
  File "pyarrow\pandas-shim.pxi", line 126, in pyarrow.lib._PandasAPIShim.pd.__get__
  File "pyarrow\pandas-shim.pxi", line 96, in pyarrow.lib._PandasAPIShim._check_import
  File "pyarrow\pandas-shim.pxi", line 56, in pyarrow.lib._PandasAPIShim._import_pandas
ModuleNotFoundError: No module named 'pyarrow.vendored.version'

Any advice would be appreciated. Meanwhile, I’m going to convert it to a markdown table so it would work, but would much prefer st.table