Cannot import name 'cli' from 'streamlit'

Hi I am using stramlit in one of my project intrgrated with python.
previouly it used to work.
I created a new conda envirment and installed all the packeges and when i am trying to run it again it is giving me this error as " from streamlit import cli as stcli
ImportError: cannot import name ‘cli’ from ‘streamlit’ (C:\–path—\Anaconda3\envs\AIRT\lib\site-packages\streamlit_init_.py)"

This should be fixed if you explicitly reinstall the latest version from Conda (fix just happened 2 days ago: use streamlit.web.cli by raybellwaves · Pull Request #60 · conda-forge/streamlit-feedstock · GitHub)

1 Like

Hi!
Thanks @blackary for the link to the pull request. I do have the exact same issue as @Pravin_Kalse and unfortunately, was not able to solve it by installing streamlit through Conda with the conda-forge channel… The installation was successful but I still have the problem :confused:

from streamlit import cli as stcli
ImportError: cannot import name 'cli' from 'streamlit' (C:\...\anaconda3\envs\my_env\lib\site-packages\streamlit\__init__.py)

The issue only occur when I try to run my project on Windows, whereas I have no issue when I run it on OSX. That is a very incapacitating issue :frowning:

EDIT: was able to fix the issue by changing my import line to:

from streamlit.web import cli as stcli

I believe the issue is due to a change in the structure of the source code, moving cli.py from the main streamlit folder to a web subfolder. Sorry if this was clear for you from the beginning, I just had to wrap my head around the source code to understand that because the thread of the PR in itself wasn’t very helpful for me :sweat_smile:

1 Like

Sorry @jlg, I misread the issue you were having. Your solution is definitely the correct one.

Thank you, your solution works for me :green_heart: :green_heart:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.