-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Streamlit 1.34] AttributeError: module 'streamlit.components' has no attribute 'v1' #8644
Comments
Hey @SiddhantSadangi , the docs state to import and use it like this import streamlit as st
import streamlit.components.v1 as components
components.html("example") This works for me in version |
Hey @raethlein Yes, it does work if imported as stated in the docs. However, it'd be great if this change can be highlighted in the docs and the |
You are welcome 🙂 I have also investigated a little bit why this changed and it seems to be that this should never have been possible, and was made transiently available via this import: There seem to be some places where we indeed advocate it like this: |
run command pip install streamlit==1.32 |
## Describe your changes Closes #8644 From [this comment](#8644 (comment)): The usage of `components.html` via `st.components.v1.html` was possible prior to `1.34` due to [this import](https://github.com/streamlit/streamlit/pull/8457/files#diff-3f73cf34a1595773b3b79ea85c5efd0c208e23beec4f812fa05419f87cff597eL32): `from streamlit.components.v1.components import ComponentRegistry`, which made it transiently available. This means that the usage via `st.components.v1.html` is only possible when `server.py` is imported at one point, which is not the case for example when running Streamlit as a bare-script. We have discussed this and thought about bringing the behavior back, but this time explicitly and with tests 🙂 Final decision is still pending. ## Testing Plan - E2E Tests - Added new e2e test to test this import behavior. The tests are added as extra files in order to start with a fresh context and not accidentally have transient imports that make it appear as if it works. --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
@SiddhantSadangi We have just merged a PR to add this way of importing back. We do not advocate it as the other way feels cleaner, but if you are curious to test it out you could get the wheel from the PR or wait for the nightly build tonight. Otherwise it will be available in version |
Checklist
Summary
Streamlit v1.34 seems to have removed
v1
fromstreamlit.components
, leading to anAttributeError
when trying to usestreamlit.components.v1.html()
.There is no mention of any such change in the changelog, and the documentation still includes
v1.html()
in v1.34.0: https://docs.streamlit.io/develop/api-reference/custom-components/st.components.v1.htmlstreamlit.html()
does not support all features supported bycomponents.v1.html()
, likeheight
, and is not a good enough substitute yet.Reproducible Code Example
Steps To Reproduce
Expected Behavior
v1.html()
should be an attribute ofstreamlit.components
Current Behavior
Is this a regression?
Debug info
Additional Information
Using as
streamlit._main._html()
works.Using as
also works.
The text was updated successfully, but these errors were encountered: