Although there are multiple posts on stack overflow about custom module not found error, but those solutions (such as this one) didn't help in my case.
My folder structure is like this:
project
|-- app
| |-- script.py
|-- src
| |-- __init__.py
| |-- file.py
In my script.py
I have this code
import pandas as pd
import streamlit as st
from project.src.file import func
Using VS Code in a windows7 machine, I changed the directory to project
, and activated a conda virtual environment, then executed the code streamlit run app\script.py
, I got this error
ModuleNotFoundError: No module named 'project'
Changing the script to from src.file import func
caused this error
ModuleNotFoundError: No module named 'src'
Could someone please explain what happened? Why Python couldn't find my custom module even though I had the required __init__.py
in the folder src
.