Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
WaldekGizynski opened this issue May 27, 2024 · 5 comments · May be fixed by #280
Open

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

WaldekGizynski opened this issue May 27, 2024 · 5 comments · May be fixed by #280

Comments

@WaldekGizynski
Copy link

WaldekGizynski commented May 27, 2024

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: streamlit/streamlit#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
Copy link

Issue is mitigated when moving to version 1.32

@danialcheung
Copy link

I've proposed a simple PR for this here.

@matthalstead-mfe
Copy link

Would be good news to have this PR accepted.

@JohnnyDev818
Copy link

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
Copy link

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!

@danialcheung danialcheung linked a pull request Dec 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants