Hello everyone, I’ve encountered an issue with importing modules while developing a Streamlit app locally. My project structure is as follows:
Project/
├── src/
│ ├── utils/
│ │ └── processing.py
│ ├── pages/
│ │ └── page_2.py
└── main.py
In page_2.py
, I want to import the processing.py
module located in the utils
directory, which is a level up. When I try to use the relative import statement
from ..utils import processing as proc
,
I encounter the following error:
ImportError: attempted relative import with no known parent package
The Streamlit app is run with the command streamlit run main.py
from the src
directory. Is there a way to correctly import the module from the parent directory? Or how should I adjust my project structure to avoid this issue?
Thanks for your help!