How to setup workspace folder as root folder in VS Code to run python pipelines

33 Views Asked by At

I have a folder structure in VS code as follows:

project
├── functions/
│   ├── __init__.py
│   ├── my_module.py
└── pipeline/
│   ├── __init__.py
│   ├── run_code.py
└── setup.py/

folder image

inside the run_code.py, it imports function from functions.my_module import new_func. however, it is giving ModuleNotFoundError.

I tried below points:

  1. Added below in settings.json
    "python.analysis.extraPaths`":["${workspaceFolder}"],
    "launch": {     "configurations": [],
    "compounds": [],
    "cwd": "${`workspace Folder\`}"
    },
  1. tested with adding sys.path.append() at top and it worked. But this is not a standard way
  2. Added init.py in each subfolders and it is not working

Kindly help.

0

There are 0 best solutions below