Discovered Streamlit today, going down the Get Started section, but Pandas with styler example does not work.
Steps to reproduce
I am talking about this example:
Code snippet:
import streamlit as st
import numpy as np
import pandas as pd
dataframe = pd.DataFrame(
np.random.randn(10, 20),
columns=('col %d' % i for i in range(20)))
st.dataframe(dataframe.style.highlight_max(axis=0))
Expected behavior:
Expected to see a dataframe in the browser.
Actual behavior:
Instead, I get: KeyError:‘warnings’
Followed by a long Traceback:
File "C:\programs\gttools\python3\3.10.5\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 564, in _run_script
exec(code, module.__dict__)
File "C:\Users\salazag\programs\streamlit\htp3\htp3.py", line 10, in <module>
dataframe = pd.DataFrame(
File "C:\programs\gttools\python3\3.10.5\lib\site-packages\pandas\core\frame.py", line 721, in __init__
mgr = ndarray_to_mgr(
File "C:\programs\gttools\python3\3.10.5\lib\site-packages\pandas\core\internals\construction.py", line 345, in ndarray_to_mgr
index, columns = _get_axes(
File "C:\programs\gttools\python3\3.10.5\lib\site-packages\pandas\core\internals\construction.py", line 753, in _get_axes
columns = ensure_index(columns)
File "C:\programs\gttools\python3\3.10.5\lib\site-packages\pandas\core\indexes\base.py", line 7374, in ensure_index
return Index._with_infer(index_like, copy=copy, tupleize_cols=False)
File "C:\programs\gttools\python3\3.10.5\lib\site-packages\pandas\core\indexes\base.py", line 715, in _with_infer
with warnings.catch_warnings():
File "C:\programs\gttools\python3\3.10.5\lib\warnings.py", line 446, in __init__
self._module = sys.modules['warnings'] if module is None else module
Debug info
Streamlit version: 1.15.2
Python version: 3.10.5
Using Conda? PipEnv? PyEnv? Pex? No. Working locally with Python installations and site-packages.
OS version: Windows 10, Version 21H2
Browser version: Edge Version 107
Requirements file
No, working locally with everything already installed.
Can you insert the version checks right after the import lines and see if it can execute that? If so, what versions did you get? If not, can you try a new environment or maybe try reinstalling the modules?
Yeah, seems like something. Looks like Streamlit is running fine with the simple write version commands and you’ve got the same combo as one of the environments I used. Can you spin up a clean environment to try? Or since the errors seem to be in pandas, you might try reinstalling that module.
((Are you familiar with using environments to make it easy to play around with different module versions? I’m on my tablet, but can pop over to desktop to grab a few easy directions. Do you just have Python installed directly? Do you have Anaconda? I like Anaconda for easy environment management.))
Yes, I know my way around environments. So, let me start anew; maybe something happened after I installed one too many web frameworks…I have been reading up online and experimenting with flet, flask, nicegui, web2py, streamlit…looking for the one I would like.
Were you able to run the code in a clean environment?
As for which is best, I think it highly depends on your use case/skills. One of Streamlit’s strong points is that you get to an operable dashboard with very little code and that it’s probably one of the most beginner friendly options.
However, if your goal is a broader, more generic web framework, you’ll probably feel constrained in Streamlit.
This web stuff is all new to me, but, apparently, the direction new management wants to go; so, here I am.
I am an engineer and work for an engineering department, but moved to the software side of things some years ago. Given that the know-how is proprietary and very technical, most in-house software is written by engineers with little software knowledge and even less interest in developing such skill…this is one reason why I typically prefer/search easy-to-use options.
So, I started with a clean Python installation and “only” installed streamlit…the example now works.
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.