I am trying to do an import in python from one directory level up.
import sys
sys.path.append(\'..\')
from cn_modules import exception
I g
There are two ways. Directly put it in launch.json or use a .env file.
All in launch.json
launch.json
"env": {"PYTHONPATH": "${workspaceRoot};${workspaceRoot}/modules;${workspaceRoot}/modules/somePrj/modules"}
Use a .env file
launch.json
"envFile": "${workspaceRoot}/.env"
.env
PYTHONPATH=".;modules;/modules/somePrj/modules"
The .env file way is recommended for we can choose prod.env or test.env.