I have an issue with importing modules from a subfolder in my projects main folder.
The project structure is:
project_folder/
|-- main.py
|
|-- tools/
|-- script.py
|
|-- utils/
|--__init__.py
|--misc.py
When I try to import a function from the utils.misc
module, I get a ModuleNotFoundError
(using VSCode), but I can run the code with no issue when I use Spyder.
The statement I use in script.py to import is:
from utils.misc import my_function
How can I resolve this issue?
Please see a snapshot of the error below:
I have also added ${workpsaceFolder}
to cwd
configuration, and added the project root folder to the PYTHONPATH
in the launch.json
file (see below). However the project_folder
still fails to show up when I print sys.path
.
UPDATE: See the screenshot of the project structure and the error below