I'm trying to setup a python project in Visual Studio Code. My problem is to create and use the src
directory as source root (like it is working in pycharm). I have this directory structure:
project_name\
src\
__init__.py
dta\
__init__.py
dtapy.py
tests\
__init__.py
tet.py
My problem occurs e.g. with this code:
import dta.dtapy
print('ok')
I get the message:
File ".../project_name/scr/tests/tet.py", line 1, in import dta.dtapy ModuleNotFoundError: No module named 'dta'
I tried several tips like:
- add
.env
file with:PYTHONPATH=src
to root directory - setup
launch.json
with:"cwd": "${workspaceFolder}/src",
What is the proper way to setup this correctly in VS Code?