Toml decoder error (TomlDecodeError)

Yes found it and it solved the issue. Thanks!

Glad it worked out.

Just a note for others, if you’re on a Windows system dot files/folders (like .streamlit/) may be hidden by default. You’ll have to change that to see this file in your directory.

1 Like

Hi @eriktuck,

Quick question, are you seeing the file at C:/Users/Erik/.streamlit.config.toml or at C:/Users/Erik/.streamlit/config.toml?

Also did you create this file manually?

1 Like

Right. I found the file at C:/Users/Erik/.streamlit/config.toml. Typo on my part.

I was able to recreate the error. I am deploying my app to Heroku. I have a setup.sh file. If I run the setup.sh file outside of the Heroku environment (e.g., double click the file on my computer), it populates the config.toml file with the single line. The setup.sh file contents are pasted below, so you can see how this is happening. I’m running Windows 8.1 locally.

mkdir -p ~/.streamlit/

echo "\
[general]\n\
email = \"your-email@domain.com\"\n\
" > ~/.streamlit/credentials.toml

echo "\
[server]\n\
headless = true\n\
enableCORS=false\n\
port = $PORT\n\
" > ~/.streamlit/config.toml
3 Likes

Hi Erik
I am having similar issue and couldn’t find the config file. I am using MacBook. I can see the streamlit folder but no config.toml file.

Welcome to the forum @KIRTISNIGDHA :wave: ,

This thread might help answer your question. Feel free to let us know if you need any additional help!

1 Like

Hey Erik,
I did find the config.toml file but how do I edit it now, as in where can I find the appropriate content of the file?

I deleted the file entirely. You might, to be safe, simply move it to a different directory and/or change the name of the file. But, for me, deleting it solved the problem.

2 Likes

Many thanks!

Deleting Credentials.toml and Config.toml resolves my problem

2 Likes

I found I had this issue on Windows 10 when I ran:

streamlit config show > ~/.streamlit/config.toml

For example, with no config.toml file I run:

streamlit hello

And I am greeted with:

  You can now view your Streamlit app in your browser.

  Local URL: http://localhost:8501
  Network URL: http://192.168.100.75:8501

I then run:

streamlit config show > ~/.streamlit/config.toml

And then running streamlit hello I am greeted with:

PS C:\Users\sbiggs> streamlit config show > ~/.streamlit/config.toml
PS C:\Users\sbiggs> streamlit hello
Traceback (most recent call last):
  File "c:\users\sbiggs\appdata\local\continuum\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\sbiggs\appdata\local\continuum\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\sbiggs\AppData\Local\Continuum\anaconda3\Scripts\streamlit.exe\__main__.py", line 4, in <module>
  File "c:\users\sbiggs\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\__init__.py", line 103, in <module>
    from streamlit.DeltaGenerator import DeltaGenerator as _DeltaGenerator
  File "c:\users\sbiggs\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\DeltaGenerator.py", line 27, in <module>
    from streamlit import caching
  File "c:\users\sbiggs\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\caching.py", line 40, in <module>
    from streamlit.hashing import Context
  File "c:\users\sbiggs\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\hashing.py", line 41, in <module>
    from streamlit.folder_black_list import FolderBlackList
  File "c:\users\sbiggs\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\folder_black_list.py", line 39, in <module>
    if config.get_option("global.developmentMode"):
  File "c:\users\sbiggs\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\config.py", line 90, in get_option
    parse_config_file()
  File "c:\users\sbiggs\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\config.py", line 888, in parse_config_file
    _update_config_with_toml(file_contents, filename)
  File "c:\users\sbiggs\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\config.py", line 810, in _update_config_with_toml
    parsed_config_file = toml.loads(raw_toml)
  File "c:\users\sbiggs\appdata\local\continuum\anaconda3\lib\site-packages\toml\decoder.py", line 227, in loads
    original, i)
toml.decoder.TomlDecodeError: Found invalid character in key name: '#'. Try quoting the key name. (line 1 column 3 char 2)

The only way I have found to fix it, is to completely delete the file, and then write it a fresh.

Thanks Erik! this was key to solve the problem.

1 Like

Thank you so much! You helped solved it! I was struggling with this since 8 hours. I was deploying apps to heroku and idk what changed. It was working and then suddenly it stopped working!

1 Like

For Mac Users,

I came across this error while trying to deploy my app using Heroku.
so one way to solve this is by removing the config.toml file completely as most of the comments in the comment section suggest. Don’t worry about finding the config.toml file if you are planning to just delete it.

just open terminal execute these commands -

  1. streamlit config show > ~/.streamlit/config.toml
  2. rm -i ~/.streamlit/config.toml

what this will do is completly remove the config.toml file

next, test it using the command streamlit hello and things should be back to normal.

2 Likes

its Working …:slight_smile:

2 Likes

Hi Simon,

I encountered this issue after I deploy at heroku.
why heroku is able to overwrite thyis?
Thanks

I am having this issue after I edit the config.toml file as shown in the instructions on how to turn off magic printing. I only changed one line

magicEnabled = true
to
magicEnabled = false

but now I get the decode error. The error persists even after changing back to its original text. I can delete the file as suggested, but then I lose the ability to turn magic off. Maybe someone could suggest another way to prevent it from printing automatically.

Thank you so much eriktuck!!! You just saved my life. I messed up my system when trying to figure out how to present the local host to a online server with Heroku, and weirdly the codes failed to run with the same problem. I have been stayed up all night cuz I need to do a presentation with streamlit today. My mind just exploded for million times to fix the situation, and finally your way works!! Again thank you so much Savior!! Hope you have a wonderful day!

Getting the following error. Any solutions?
toml.decoder.TomlDecodeError: Key name found without value

Thanks a lot, @eriktuck. Moving the file to another directory solved it for me.