PYTHONPATH is not recongnized from launch configuration when run from code-workspace

Viewed 15

I have a workspace setup like below,

folder1
 |_ .vscode
      |_ launch.json
folder2
 |_ .vscode
      |_ launch.json

My launch.json of folder2 looks like below,

"configurations": [
        {
            "name": "Debug Unit test",
            "type": "python",
            "request": "launch",
            "justMyCode": true,
            "purpose": [
                "debug-test"
            ],
            "env": {
                "PYTHONPATH": "${workspaceFolder}/../folder1"
            }
        }
    ]

Because of the PYTHONPATH, I can step into my folder1 code and debug it. All is good.

To make my workspace look neat, I thought I will move those lines to code-workspace. However, now the PYTHONPATH is not recongnized and hence, not able to step into the folder1.

code-workspace looks like below,

"launch": {
        "configurations": [
            {
                "name": "Debug Unit test",
                "type": "python",
                "request": "launch",
                "justMyCode": true,
                "purpose": [
                    "debug-test"
                ],
                "env": {
                    "PYTHONPATH": "${workspaceFolder}/../folder1"
                }
            }
        ],
        "compounds": []
    }
1 Answers

I fixed it by having .env file and specifying in the workspace file

"settings": {"python.envFile": "${workspaceFolder}/../.env"}
Related