Can't run streamlit if I create config.toml

Hello Streamlit community!

I have encountered a small problem when wanting to change the default config.toml file.

My apps are running normally, but as soon as I create the config.toml file (wanting to change some default settings), my apps stop working, even without me actually changig the default config. This happens regardless if I create the config in user/.streamlit globally or locally within the working directory.

The error message I get:

Traceback (most recent call last):
  File "C:\Users\my_user\AppData\Local\mambaforge\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\my_user\AppData\Local\mambaforge\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\my_user\AppData\Local\mambaforge\Scripts\streamlit.exe\__main__.py", line 7, in <module>
  File "C:\Users\my_user\AppData\Local\mambaforge\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\my_user\AppData\Local\mambaforge\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Users\my_user\AppData\Local\mambaforge\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\my_user\AppData\Local\mambaforge\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\my_user\AppData\Local\mambaforge\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\my_user\AppData\Local\mambaforge\lib\site-packages\streamlit\cli.py", line 172, in main_run
    bootstrap.load_config_options(flag_options=kwargs)
  File "C:\Users\my_user\AppData\Local\mambaforge\lib\site-packages\streamlit\bootstrap.py", line 318, in load_config_options
    config.get_config_options(force_reparse=True, options_from_flags=options_from_flags)
  File "C:\Users\my_user\AppData\Local\mambaforge\lib\site-packages\streamlit\config.py", line 1013, in get_config_options
    file_contents = input.read()
  File "C:\Users\my_user\AppData\Local\mambaforge\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

Thank you for your help! And I appologize if this is spam, but I wasn’t able to find a solution already posted.

1 Like

Hey I had a similar issue. I think you need to make sure your config file is correct. your commands must include “server.maxUploadSize = 50000” with server. and not the command alone.

Thank you for your comment Misha, but unfortunately that didn’t solve the problem.

Hi @jaskozi :wave:

It would help to share what version of Streamlit you’re using and also paste the exact contents of your modified config.toml file. The following error suggests there exists a formatting issue in the file contents:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

Best, :balloon:
Snehan

Thank you for the reply Snehan.

My streamlit version is: 1.5.1

And yea, that’s the thing, I didn’t change the content of the config file.
I only did streamlit config show > config.toml

The contents of the config.toml are:

# Below are all the sections and options you can have in ~/.streamlit/config.toml.

[global]

# By default, Streamlit checks if the Python watchdog module is available and, if not, prints a warning asking for you to install it. The watchdog module is not required, but highly recommended. It improves Streamlit's ability to detect changes to files in your filesystem.
# If you'd like to turn off this warning, set this to True.
# Default: false
disableWatchdogWarning = false

# If True, will show a warning when you run a Streamlit-enabled script via "python my_script.py".
# Default: true
showWarningOnDirectExecution = true

# DataFrame serialization.
# Acceptable values: - 'legacy': Serialize DataFrames using Streamlit's custom format. Slow but battle-tested. - 'arrow': Serialize DataFrames using Apache Arrow. Much faster and versatile.
# Default: "arrow"
dataFrameSerialization = "arrow"


[logger]

# Level of logging: 'error', 'warning', 'info', or 'debug'.
# Default: 'info'
level = "info"

# String format for logging messages. If logger.datetimeFormat is set, logger messages will default to `%(asctime)s.%(msecs)03d %(message)s`. See [Python's documentation](https://docs.python.org/2.6/library/logging.html#formatter-objects) for available attributes.
# Default: None
messageFormat = "%(asctime)s %(message)s"


[client]

# Whether to enable st.cache.
# Default: true
caching = true

# If false, makes your Streamlit script not draw to a Streamlit app.
# Default: true
displayEnabled = true

# Controls whether uncaught app exceptions are displayed in the browser. By default, this is set to True and Streamlit displays app exceptions and associated tracebacks in the browser.
# If set to False, an exception will result in a generic message being shown in the browser, and exceptions and tracebacks will be printed to the console only.
# Default: true
showErrorDetails = true


[runner]

# Allows you to type a variable or string by itself in a single line of Python code to write it to the app.
# Default: true
magicEnabled = true

# Install a Python tracer to allow you to stop or pause your script at any point and introspect it. As a side-effect, this slows down your script's execution.
# Default: false
installTracer = false

# Sets the MPLBACKEND environment variable to Agg inside Streamlit to prevent Python crashing.
# Default: true
fixMatplotlib = true

# Run the Python Garbage Collector after each script execution. This can help avoid excess memory use in Streamlit apps, but could introduce delay in rerunning the app script for high-memory-use applications.
# Default: true
postScriptGC = true


[server]

# List of folders that should not be watched for changes. This impacts both "Run on Save" and @st.cache.
# Relative paths will be taken as relative to the current working directory.
# Example: ['/home/user1/env', 'relative/path/to/folder']
# Default: []
folderWatchBlacklist = []

# Change the type of file watcher used by Streamlit, or turn it off completely.
# Allowed values: * "auto" : Streamlit will attempt to use the watchdog module, and falls back to polling if watchdog is not available. * "watchdog" : Force Streamlit to use the watchdog module. * "poll" : Force Streamlit to always use polling. * "none" : Streamlit will not watch files.
# Default: "auto"
fileWatcherType = "auto"

# Symmetric key used to produce signed cookies. If deploying on multiple replicas, this should be set to the same value across all replicas to ensure they all share the same secret.
# Default: randomly generated secret key.
cookieSecret = "2f926bcba7c65336ef8e432c52ab0673a06b9f29860e5202008a3d5847b876bd"

# If false, will attempt to open a browser window on start.
# Default: false unless (1) we are on a Linux box where DISPLAY is unset, or (2) we are running in the Streamlit Atom plugin.
headless = false

# Automatically rerun script when the file is modified on disk.
# Default: false
runOnSave = false

# The address where the server will listen for client and browser connections. Use this if you want to bind the server to a specific address. If set, the server will only be accessible from this address, and not from any aliases (like localhost).
# Default: (unset)
#address =

# The port where the server will listen for browser connections.
# Default: 8501
port = 8501

# The base path for the URL where Streamlit should be served from.
# Default: ""
baseUrlPath = ""

# Enables support for Cross-Origin Request Sharing (CORS) protection, for added security.
# Due to conflicts between CORS and XSRF, if `server.enableXsrfProtection` is on and `server.enableCORS` is off at the same time, we will prioritize `server.enableXsrfProtection`.
# Default: true
enableCORS = true

# Enables support for Cross-Site Request Forgery (XSRF) protection, for added security.
# Due to conflicts between CORS and XSRF, if `server.enableXsrfProtection` is on and `server.enableCORS` is off at the same time, we will prioritize `server.enableXsrfProtection`.
# Default: true
enableXsrfProtection = true

# Max size, in megabytes, for files uploaded with the file_uploader.
# Default: 200
maxUploadSize = 200

# Max size, in megabytes, of messages that can be sent via the WebSocket connection.
# Default: 200
maxMessageSize = 200

# Enables support for websocket compression.
# Default: true
enableWebsocketCompression = true


[browser]

# Internet address where users should point their browsers in order to connect to the app. Can be IP address or DNS name and path.
# This is used to: - Set the correct URL for CORS and XSRF protection purposes. - Show the URL on the terminal - Open the browser
# Default: 'localhost'
serverAddress = "localhost"

# Whether to send usage statistics to Streamlit.
# Default: true
gatherUsageStats = true

# Port where users should point their browsers in order to connect to the app.
# This is used to: - Set the correct URL for CORS and XSRF protection purposes. - Show the URL on the terminal - Open the browser
# Default: whatever value is set in server.port.
serverPort = 8501


[ui]

# Flag to hide most of the UI elements found at the top of a Streamlit app.
# NOTE: This does *not* hide the hamburger menu in the top-right of an app.
# Default: false
hideTopBar = false


[mapbox]

# Configure Streamlit to use a custom Mapbox token for elements like st.pydeck_chart and st.map. To get a token for yourself, create an account at https://mapbox.com. It's free (for moderate usage levels)!
# Default: ""
token = ""


[deprecation]

# Set to false to disable the deprecation warning for the file uploader encoding.
# Default: true
showfileUploaderEncoding = true

# Set to false to disable the deprecation warning for using the global pyplot instance.
# Default: true
showPyplotGlobalUse = true


[theme]

# The preset Streamlit theme that your custom theme inherits from. One of "light" or "dark".
#base =

# Primary accent color for interactive elements.
#primaryColor =

# Background color for the main content area.
#backgroundColor =

# Background color used for the sidebar and most interactive widgets.
#secondaryBackgroundColor =

# Color used for almost all text.
#textColor =

# Font family for all text in the app, except code blocks. One of "sans serif", "serif", or "monospace".
#font =

Thank you for your reply!

It looks like you may have run into an open bug caused by redirecting the output of streamlit config show to a new config.toml file.

I would try manually copying and pasting the contents into your project-specific config.toml, rather than running streamlit config show > $CWD/.streamlit/config.toml, where $CWD is the folder you’re running Streamlit from.

Let us know if that fixes the issue.

1 Like

Thank you Snehan!

It solved the problem. It would have never occured to me that the problem lies in the >.
Best,
jaskozi

1 Like

Happy to help, @jaskozi! I will let our engineers know that you encountered this bug while redirecting the output of streamlit config show.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.