I have half a day streamlit experience and I have the following issue.
The first time the server runs everything looks good. But then, when I make a change and the watcher reloads the page, I get this error
- Streamlit version: (get it with `$ streamlit version`)
- Python version: (get it with `$ python --version`)
- Using Conda? PipEnv? PyEnv? Pex?
- OS version:
- Browser version:
Also, is warnings.py your own code? Could you try renaming that file to something else?
It seems that itâs a warning thrown by the scikit library. The question is, why is it handled differently by streamlit at first load and subsequent loads?
The streamlit library is doing some funny business with sys.modules
At some point âwarningsâ is getting deleted from sys.modules
This is the bottom of the stack trace for the same issue as OP
File "/home/matt/code/monash/autumn/env/lib/python3.6/site-packages/matplotlib/cbook/deprecation.py", line 407, in _suppress_matplotlib_deprecation_warning
with warnings.catch_warnings():File "/home/matt/code/monash/autumn/env/lib/python3.6/warnings.py", line 437, in __init__
self._module = sys.modules['warnings'] if module is None else module
Something in streamlit is deleting âwarningsâ from sys.modules
for wm in self._watched_modules.values():
if wm.module_name is not None and wm.module_name in sys.modules:
if wm.module_name != "warnings":
del sys.modules[wm.module_name]
Hi @randyzwitch. My fix is really a situation-specific hack that would not be acceptible in the Streamlit codebase since it does not cover all bases. I believe that more investigation of this issue will be required before implementing a fix. If itâs helpful I can move this discussion to a GitHub issue and describe my hacky fix. (and link to issue from here)
Thatâs fair. Moving this to an issue would be great, along with your hack, so that one of our engineers can evaluate why the line that you modified is there in the first place.
Pandas KeyError occurs when we try to access some column/row label in our DataFrame that doesnât exist. Usually, this error occurs when you misspell a column/row name or include an unwanted space before or after the column/row name⊠Before doing anything with the data frame, use print(df.columns) to see dataframe column exist or not.
print(df.columns)
I was getting a similar kind of error in one of my codes. Turns out, that particular index was missing from my data frame as I had dropped the empty dataframe 2 rows. If this is the case, you can do df.reset_index(inplace=True) and the error should be resolved.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking âAccept allâ, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.