1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] when streamlit_app.py file are under nested folders then ModuleNotFound Error comes...

Discussão em 'Python' iniciado por Stack, Setembro 16, 2025.

  1. Stack

    Stack Membro Participativo

    we have streamlit based project and deployed on streamlit cloud and it was working fine when main file streamlit_app.py was under src and now move the main file under nested folder of src/alpha/streamlit_app.py and now it shows ModuleNotFoundError of import file.

    python v 3.12 and using poetry to run local


    ├── __init__.py
    ├── api/
    │ ├── __init__.py
    │ ├── fast_api.py
    │ └── routes_helper.py
    ├── assets/
    │ ├── __init__.py
    │ └── images/
    │ ├── __init__.py
    │ ├── company_logo.png
    ├── db/
    ├── features/
    │ ├── __init__.py
    │ ├── audio_recorder/
    │ │ ├── __init__.py
    │ │ └── audio_recorder_ui.py
    │ ├── image_description/
    │ │ ├── __init__.py
    │ │ └── description.py
    ├── alpha/
    │ ├── __init__.py
    │ ├── __main__.py
    │ └── streamlit_app.py
    └── utils/
    ├── __init__.py
    ├── _version.py
    ├── aws_helper.py


    here is streamlit_app.py


    import sys
    from pathlib import Path

    import streamlit as st
    from features.audio_recorder import audio_recorder_ui


    and it throw error on streamlit cloud asbelow


    /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru

    nner/exec_code.py:128 in exec_func_with_error_handling



    /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru

    nner/script_runner.py:669 in code_to_exec


    /mount/src/tz-script/src/alpha/streamlit_app.py:5 in <module>



    2 from pathlib import Path

    3

    4 import streamlit as st

    ❱ 5 from features.audio_recorder import audio_recorder_ui


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

    ModuleNotFoundError: No module named 'features'



    everything working fine in local; what could be the issue?

    even I tried to move files under alpha or give relative path src.alpha but same error

    any solution/suggestion

    Continue reading...

Compartilhe esta Página