PablocFonseca / streamlit-aggrid

Implementation of Ag-Grid component for Streamlit
https://pypi.org/project/streamlit-aggrid/
MIT License
1.05k stars 199 forks source link

AttributeError: module 'streamlit.components.v1' has no attribute 'components' #275

Open WaldekGizynski opened 4 months ago

WaldekGizynski commented 4 months ago

I use Aggrid on the site along with st.tabs. After upgrading streamlit to 1.34, an error started to occur. When the page uses st.tabs and there is a table on one of the tabs and a st.form with st.file_uploader which I reload several times, then I get this error:

selection = AgGrid( File "C:\Users...\lib\site-packages\st_aggrid__init__.py", line 396, in AgGrid except components.components.MarshallComponentException as ex: AttributeError: module 'streamlit.components.v1' has no attribute 'components'

I can't figure out what needs to be met for the error to be easily reproduced. However, I know that the error started to appear since the streamlit upgrade. The error occurs for aggrid 0.3.5 and 1.0.5 for streamlit 1.34, also 1.35. I found a somewhat related topic regarding streamlit changes here: https://github.com/streamlit/streamlit/issues/8644 I checked streamlit 1.32 and actually the error does not occur. Maybe based on this, it will be possible to determine what is the cause and solve the problem.

MarkusSagen commented 4 months ago

Issue is mitigated when moving to version 1.32

danialcheung commented 3 months ago

I've proposed a simple PR for this here.

matthalstead-mfe commented 2 months ago

Would be good news to have this PR accepted.

JohnnyDev818 commented 3 weeks ago

Bumping this up. I am having the same issue as the original poster. Very intermittent and difficult to reproduce. I am using Streamlit 1.38 and I can't go back to 1.32.

Will bribe with lots of coffee's :-).

danialcheung commented 2 weeks ago

For anyone still experiencing this error, it's due to Streamlit renaming their module from components.py to custom_component.py.

The solution is a two-line fix within st_aggrid/__init__.py you can do yourself.

Simply replace the two instances of components.components.MarshallComponentException with components.custom_component.MarshallComponentException at lines 348 and 352.

You can view the details of this in the PR I've submitted, but I don't think it'll be accepted any time soon.

I hope this manages to fix things!