skip to Main Content

I tried to set up PYTHONPATH environmental variable in vscode in Mac, and it does not work. VScode version: Version: 1.78.1 (Universal), Mac os: 13.3.1 (a)
I followed the instruction:
https://code.visualstudio.com/docs/python/environments#_use-of-the-pythonpath-variable
In workspace setting.json

{
    "workbench.colorCustomizations": {
        "editorLineNumber.foreground": "#00ff00"
    },
    "terminal.integrated.env.osx": {
        "PYTHONPATH": "${workspaceFolder}/src",
        "ABC": "124"
    }
}

In the terminal, I type

echo $PYTHONPATH

and it returns:

/usr/local/Cellar/apache-spark/3.3.2/libexec/python/

I then set PYTHONPATH in user settint.json like this

{
    "terminal.integrated.defaultProfile.osx": "bash",
    "terminal.integrated.inheritEnv": false,
    "terminal.integrated.env.osx": {
        "PYTHONPATH": "${workspaceFolder}/src"
    }
}

I closed vs code and reopened, and type

echo $PYTHONPATH

and got same result.

I also set PYTHONPATH in .env right under workspace

PYTHONPATH=/Users/{user_name}/gitlab/aws/dummy_project

it does not work either.

Can anyone help on this?

2

Answers


  1. Chosen as BEST ANSWER

    I found I define

    export PYTHONPATH={some value}
    

    in .bash_profile. After I commenting this line, setting in terminal.integrated.env.osx works.


  2. steps to configure the python path in vscode:
    enter image description here

    enter image description here

    Then add python.exe path enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search