No module named streamlit.__main__; 'streamlit' is a package and cannot be directly executed

Hello guys,

When i try to deploy streamlit to heroku i get this below error.How can i fix it?

No module named streamlit.main; ‘streamlit’ is a package and cannot be directly executed

What versions of python are you running?

1 Like

Hey @M11, welcome to Streamlit!

The streamlit command lives in your virtualenv’s bin/ folder. It looks like pipenv run isn’t looking in that folder, and is instead finding the package called streamlit, and trying to execute that instead.

Without seeing any details of what your Heroku deployment looks like, it’s hard to offer concrete advice to fix this issue. But from your screenshots, it looks like you’re executing this command from within a pipenv shell. Since you’re already in the shell, you don’t need to use pipenv run streamlit run ... to run the streamlit command; having the shell activated means that the streamlit command will already be on your $PATH.

When you have the shell active, doing this should work instead:

streamlit run

Alternately, you could forego pipenv and manage your virtualenv directly. I’ve put together a minimal working example of a Streamlit app that’s deployable to Heroku. It uses a plain requirements.txt file instead of a Pipfile:

1 Like