ModuleNotFoundError: No module named 'streamlit.cli'
Asked Answered
W

7

8

I have an error when I deploy streamlit app on Heroku. How can I deal with ?

something error like this

Waugh answered 28/6, 2021 at 11:0 Comment(0)
H
14

This happens when you Install multiple streamlit packages from different folders like when you cloned a project and you install their requirements in your global environment In this case best possible thing that can be done is to uninstall streamlit dependencies present in your system by

pip uninstall streamlit

The install it again using,

pip install streamlit

It should remove all the conflicts and your application should work now. and remember to install the new requirements in your virtual environment if you install all the requirements in your global environments these conflicts occur.

then simply run streamlit run command using

streamlit run app.py

All things should work fine now.

Hash answered 1/5, 2022 at 11:3 Comment(0)
R
9

Try upgrading streamlit (this worked for me)

pip install --upgrade streamlit

Otherwise reinstall

pip uninstall streamlit
pip install streamlit
Resht answered 23/4, 2023 at 1:11 Comment(1)
first option worked best for me.Jenn
A
4

For me following command worked in mac

conda update -c conda-forge streamlit -y
Achene answered 18/1, 2024 at 6:42 Comment(0)
R
3

Updating the answer here for future users.

The package has been moved to streamlit.web module. So the current way is,

import streamlit.web.cli as stcli
Revoke answered 29/6, 2023 at 3:42 Comment(0)
M
1

You need to do the following steps:

  1. Create the virtualenv.
  2. Activate virtualenv.
  3. Then, you need to install the following packages:
pip install streamlit
pip install networkx

You would also install any other dependencies you need to run your script as well before running:

streamlit run yourscript.py
Mend answered 28/6, 2021 at 11:24 Comment(3)
I have created an environment, and I check my "requirements.txt" file, I lack the package "networkx", when I install finished and deploy again, the problem still exist .Waugh
Did you install the requirements.txt file using pip install -r requirements.txt? Install the package "networkx" separately then.Mend
I creates a app on heroku, not on my local. So packages are installed at the same time from "requirements.txt"Waugh
V
1

Open Anaconda and click on Environments Then click on Play button and then click on Open Terminal

Anaconda

If you use Python 3 then install apt pip through:

sudo apt-get install python3-pip

Then Install pipenv through

pip3 install pipenv

Then you can install streamlit through:

pipenv install streamlit

You can run python files through streamlit as usual:

streamlit run my_file.py

Create a new environment with streamlit

Directly go to the folder where your project is located, click on the address bar then click on "Copy link as text", then change your working directory through

cd /your_copied_path

Create a new pipenv environment in that folder

pipenv

You can again install streamlit through pipenv:

pipenv install streamlit

Then you can just open your streamlit python file:

streamlit my_file.py

If this answer was helpful you can just like by clicking heart

Thanks for reading!!!

Vimen answered 17/10, 2022 at 23:39 Comment(1)
Welcome to StackOverflow. Asking for upvotes is NOT allowed, please edit your answer, thanks.Hamhung
B
0

I managed to get it to work by killing the current terminal and opening a new one. Then activating the virtual environment.

  1. kill the current VS Code terminal
  2. Open a new terminal in VS Code
  3. Activate the virtual environment source venv/bin/activate

https://discuss.streamlit.io/t/streamlit-does-not-use-venv/10791/2

Bakken answered 6/6, 2024 at 23:0 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.