How to configure python environs for Visual Studio Code
Clarice Bouwer

Clarice Bouwer @cbillowes

About: Curious programmer sharing byte-sized knowledge on dev.to. Passionate about Git, GCP, TypeScript, Next.js, and DevTools. Enjoys collaborating with others and leading by example.

Location:
Mauritius
Joined:
May 30, 2018

How to configure python environs for Visual Studio Code

Publish Date: Jul 29 '23
3 0

If you need to store environment variables for Python that does not automatically get detected by VS Code then this answer should hopefully help you.

I am doing a Data Science bootcamp and need to store a specific path for one of my challenges.

Exporting PYTHONPATH in ~/.zshrc works perfectly when I run the notebook directly from Juypter, however the environment variable is not detected through VS Code.

I created a global file in my home directory from the pwd (present working directory) that I wanted to store in my path:

echo "export PYTHONPATH=$(pwd):$PYTHONPATH" >> ~/.python-env
Enter fullscreen mode Exit fullscreen mode

I opened the JSON User Settings in VS Code and added the python.envFile setting which points directly to ~/.python-env

{
    "python.envFile": "~/.python-env"
}
Enter fullscreen mode Exit fullscreen mode

Comments 0 total

    Add comment