FAQ: ModuleNotFoundError

Problem

When you run your app locally or on Streamlit Community Cloud, you see an error message that starts with ModuleNotFoundError.

Solution

If you’re running your app locally, you’re seeing this error message because you haven’t installed all the dependencies used by your app. Use pip or your package manager of choice to install the packages used by your app (you can also add a list of your app’s dependencies to a requirements.txt file and run pip install -r requirements.txt to install them all).

If your app is deployed on Streamlit Community Cloud, the GitHub repository for your app is likely missing a requirements.txt file (never heard of a requirements.txt file? Check out this guide). Add a requirements.txt file that contains the full list of your app’s dependencies to your app’s repo.

Here’s an example of what the contents of your requirements.txt file might look like:

streamlit
openai
llama-index==0.10.4
nltk
httpx
pypdf

If your repo already includes a requirements.txt file, that file is most likely missing the dependency mentioned in the error message.

Resources