Summary
I used pyinstaller to create an executable from my streamlit app. When running the executable, I get the following error when the app tries to display a pandas dataframe with either st.dataframe or st.table.
Steps to reproduce
- I created a module run.py
import streamlit as st
from pathlib import Path
import pandas as pd
import datetime
import numpy as np
from plotly.subplots import make_subplots
from plotly import graph_objects as go
import plotly.express as px
# These imports are needed for the streamlit execution below.
import streamlit.web.cli as stcli
import sys
import streamlit.runtime.scriptrunner.magic_funcs
if __name__ == "__main__":
sys.argv=["streamlit", "run", "streamlit_app.py","--global.developmentMode=false"]
sys.exit(stcli.main())
- With the pip environment activated, I run the command:
pyinstaller --copy-metadata streamlit --collect-data streamlit ./run.py --noconfirm
-
I copy my streamlit_app.py in the created “dist” folder where the executable is.
-
I run the executable
The app works, but crashes with the following error message (which does not occur when running the app directyl with “streamlit run streamlit_app.py”
ModuleNotFoundError: No module named 'pyarrow.vendored.version'
Traceback:
File "streamlit\runtime\scriptrunner\script_runner.py", line 565, in _run_script
File "D:\code\ladlegate_streamlit\dist\run\streamlit_fdi.py", line 909, in <module>
main(cfg)
File "D:\code\ladlegate_streamlit\dist\run\streamlit_fdi.py", line 656, in main
with tab1: st.table(metadata.overview.loc[metadata.overview.set_id == set_id])
File "streamlit\runtime\metrics_util.py", line 311, in wrapped_func
File "streamlit\elements\dataframe_selector.py", line 156, in table
File "streamlit\runtime\metrics_util.py", line 311, 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 759, in data_frame_to_bytes
File "pyarrow\table.pxi", line 3557, in pyarrow.lib.Table.from_pandas
arrays, schema, n_rows = dataframe_to_arrays(
File "pyarrow\pandas_compat.py", line 571, 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__
self._check_import()
File "pyarrow\pandas-shim.pxi", line 96, in pyarrow.lib._PandasAPIShim._check_import
self._import_pandas(raise_)
File "pyarrow\pandas-shim.pxi", line 56, in pyarrow.lib._PandasAPIShim._import_pandas
from pyarrow.vendored.version import Version
Debug info
- Streamlit version:1.18.1
- Python version: 3.7.9
- Using standard python environment
- OS version: Windows
- Browser: Google Chrome
Requirements file
Package Version
------------------------- -----------
altair 4.2.2
altgraph 0.17.3
attrs 22.2.0
backports.zoneinfo 0.2.1
blinker 1.6.2
cachetools 5.3.0
certifi 2022.12.7
charset-normalizer 3.1.0
click 8.1.3
colorama 0.4.6
cycler 0.11.0
decorator 5.1.1
entrypoints 0.4
fonttools 4.38.0
gitdb 4.0.10
GitPython 3.1.31
idna 3.4
importlib-metadata 6.3.0
importlib-resources 5.12.0
Jinja2 3.1.2
jsonschema 4.17.3
kiwisolver 1.4.4
markdown-it-py 2.2.0
MarkupSafe 2.1.2
matplotlib 3.5.3
mdurl 0.1.2
numpy 1.21.6
packaging 23.1
pandas 1.3.5
pefile 2023.2.7
Pillow 9.5.0
pip 23.0.1
pkgutil_resolve_name 1.3.10
plotly 5.14.1
protobuf 3.20.3
pydeck 0.8.0
Pygments 2.15.0
pyinstaller 5.10.0
pyinstaller-hooks-contrib 2023.2
Pympler 1.0.1
pyparsing 3.0.9
pyrsistent 0.19.3
python-dateutil 2.8.2
pytz 2023.3
pytz-deprecation-shim 0.1.0.post0
pywin32-ctypes 0.2.0
requests 2.28.2
rich 13.3.4
semver 3.0.0
setuptools 47.1.0
six 1.16.0
smmap 5.0.0
streamlit 1.18.1
tenacity 8.2.2
toml 0.10.2
toolz 0.12.0
tornado 6.2
typing_extensions 4.5.0
tzdata 2023.3
tzlocal 4.3
urllib3 1.26.15
validators 0.20.0
watchdog 3.0.0
zipp 3.15.0
Additional information
I also reproduced the procedure described in https://discuss.streamlit.io/t/using-pyinstaller-or-similar-to-create-an-executable/902/72? but I observed the same error.