Theme defined in the config.toml file is not applying when the app is packaged using PyInstaller

Hello Streamlit Community,I’m encountering an issue where the theme defined in my config.toml file is not being applied when I package my Streamlit app using PyInstaller.

Details:

  • Streamlit Version: 1.37.0
  • PyInstaller Version: 6.10.0
  • Operating System: macOS 13.5.1 (22G90), Apple M1 Pro, 16GB Memory
  • GitHub Repository: GitHub - ncrevois/streamlit_dash

Problem:

I have a config.toml file located in the .streamlit directory of my project, containing the following theme settings:

[theme]
primaryColor=“#d7ffcd” # Light green color for primary elements
backgroundColor=“#2C2C2C” # Dark grey background color
secondaryBackgroundColor=“#373737” # Slightly lighter grey for secondary backgrounds
textColor=“#E8E8E8” # Light grey color for text to ensure readability
font=“sans serif”

Despite confirming that the config.toml file is correctly placed in the expected directory within the packaged app, the theme is not applied when I run the app.

Steps Taken:

  1. Verified that the config.toml file is in the correct location within the packaged app.
  2. Checked the contents of the config.toml file to ensure it is correct.
  3. Used debug statements in my app to confirm that the path to the config.toml is being set correctly.
  4. Attempted to set the theme programmatically as a fallback, but the issue persists.

Debug Information:

I’ve added debug statements to my app, which show the following:

Base path: /var/folders/lh/_4t9rdq96nldc1n0f9y9cc0c0000gn/T/_MEIOhzQ9O
Config path: /var/folders/lh/_4t9rdq96nldc1n0f9y9cc0c0000gn/T/_MEIOhzQ9O/.streamlit
STREAMLIT_CONFIG_DIR: /var/folders/lh/_4t9rdq96nldc1n0f9y9cc0c0000gn/T/_MEIOhzQ9O/.streamlit
Current working directory: /Users/nathaliecrevoisier
config.toml found at: /var/folders/lh/_4t9rdq96nldc1n0f9y9cc0c0000gn/T/_MEIOhzQ9O/.streamlit/config.toml

The debug output confirms that the config.toml file is present in the expected location within the packaged app.

Any insights or suggestions on how to resolve this would be greatly appreciated.

Ok, I found a way to do that, adding it here in case anyone ever wonders the same thing again:

  • I ended up adding it as an argument in my run.py function instead and that worked

sys.argv = [
“streamlit”,
“run”,
streamlit_app_path,
“–global.developmentMode=false”,
“–theme.backgroundColor=#2C2C2C”,
“–theme.primaryColor=#d7ffcd”,
“–theme.secondaryBackgroundColor=#373737”,
“–theme.textColor=#E8E8E8”,
“–theme.font='sans serif'”
]

2 Likes