I’m having a fight between my linter
pyright and a streamlit module error. Here’s my project structure:
project_folder | --> Pipfile, etc | --> project | --> __init__.py | --> base.py | --> submodule | --> __init__.py | --> base2.py
My main entrypoint is in
base.py, which I call with
streamlit run project/base.py with my terminal located in
project_folder. But when I run the script and try to import a function from base2, I get the following errors:
from project.submodule.base2 import X
ModuleNotFoundError: No module named 'project'
from .submodule.base2 import X
ModuleNotFoundError: No module named '__main__.submodule'; '__main__' is not a package
However, if I break the linter convention and perform a relative import with:
from submodule.base2 import X
my module loads successfully and the streamlit page runs.
Could you advise on best practice regarding how to deal with imports? Tested this with 0.73.0 and 0.74.1. All scripts were working yesterday, not today.