ModuleNotFoundError: No module named 'streamlit'

Hello there, this is my first post.

  1. This is my public app (deployed on Community Cloud): https://digcompedu-dashboard.streamlit.app/
  2. This is the link to my app’s public GitHub repository (including a requirements file).
  3. The full text of the error message (not a screenshot) is:
    Traceback (most recent call last):
    File “/mount/src/digcompedu-dashboard/init.py”, line 1, in
    import streamlit as st
    ModuleNotFoundError: No module named ‘streamlit’
  4. Streamlit 1.38.0 and Python 3.11.

I have a subprocess py-Script that is executed in the streamlit_app.py - it works perfectly fine in the codespaces IDE, but fails when accessing it via the public link.

My requirements.txt:

streamlit
pandas
requests
matplotlib
seaborn

I have a feeling I’m missing something here, and am grateful for your help!

Thanks in advance!

Sonja

Hi @Sonja

Thanks for your question, we actually have an FAQ post on this topic:

Thank you for your prompt answer.

I saw this FAQ post. I forgot to mention: streamlit is installed and also mentioned in the requirements.txt. The solution offered in this post therefore does not seem to be working for me.

Is there any other way this error could occur?

Edit:
I have tried modifying the requirements.txt by adding / removing packages that are loaded there.
Find the log below. Possibly this gives more insight. As for now I’m convinced that I followed all the instructions in the FAQ post. It looks to me like the uv pip is not up to date and might cause the error? I’m not sure, though. Is there anything I can do?

Edit2: I renamed the subprocess script file to launch.py and adjusted the appscript accordingly.

LOGFILE

Using uv pip install.

× No solution found when resolving dependencies:

╰─▶ Because subprocess was not found in the package registry and you require

  subprocess, we can conclude that the requirements are unsatisfiable.

Checking if Streamlit is installed

Found Streamlit version 1.36.0 in the environment

────────────────────────────────────────────────────────────────────────────────────────

──────────────────────────────────────── pip ───────────────────────────────────────────

Using standard pip install.

Collecting streamlit (from -r /mount/src/digcompedu-dashboard/requirements.txt (line 1))

Downloading streamlit-1.36.0-py2.py3-none-any.whl.metadata (8.5 kB)

Collecting pandas (from -r /mount/src/digcompedu-dashboard/requirements.txt (line 2))

Downloading pandas-2.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (19 kB)

Collecting requests (from -r /mount/src/digcompedu-dashboard/requirements.txt (line 3))

Downloading requests-2.32.3-py3-none-any.whl.metadata (4.6 kB)

Collecting matplotlib (from -r /mount/src/digcompedu-dashboard/requirements.txt (line 4))

Downloading matplotlib-3.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (11 kB)

Collecting seaborn (from -r /mount/src/digcompedu-dashboard/requirements.txt (line 5))

Downloading seaborn-0.13.2-py3-none-any.whl.metadata (5.4 kB)

Collecting datetime (from -r /mount/src/digcompedu-dashboard/requirements.txt (line 6))
Downloading DateTime-5.5-py3-none-any.whl.metadata (33 kB)
ERROR: Ignored the following versions that require a different python version: 0.55.2 Requires-Python <3.5
ERROR: Could not find a version that satisfies the requirement subprocess (from versions: none)
ERROR: No matching distribution found for subprocess
[notice] A new release of pip is available: 24.0 → 24.1

[notice] To update, run: pip install --upgrade pip
Checking if Streamlit is installed
Found Streamlit version 1.36.0 in the environment
────────────────────────────────────────────────────────────────────────────────────────
[06:06:48] :exclamation: installer returned a non-zero exit code
[06:41:51] :octopus: Pulling code changes from Github…
[06:41:52] :package: Processing dependencies…
──────────────────────────────────────── uv ───────────────────────────────────────────
Using uv pip install.

Resolved 48 packages in 123ms
Audited 48 packages in 0.12ms
Checking if Streamlit is installed
[06:41:52] :desktop_computer: Provisioning machine…
Found Streamlit version 1.36.0 in the environment
────────────────────────────────────────────────────────────────────────────────────────
[06:41:53] :snake: Python dependencies were installed from /mount/src/digcompedu-dashboard/requirements.txt using uv.
[06:41:53] :package: Processed dependencies!
[06:41:53] :control_knobs: Preparing system…
[06:41:53] :chains: Spinning up manager process…
[06:41:57] :arrows_counterclockwise: Updated app!


→ even if there is no error message here, in the browser the app displays the error

  File "/mount/src/digcompedu-dashboard/launch.py", line 1, in <module>
    import streamlit as st
ModuleNotFoundError: No module named 'streamlit'
type or paste code here

subprocess is part of the standard library, you cannot install it separately.

I understand, thanks for the remark. However, even when removing it from the requirements.txt, the error message displays.

Use sys.executable instead of "python".

This worked, thanks! I had to make sure sys is imported, but then it worked for me.

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