I need to re-define the PYTHONPATH within Visual Studio Code (VSC) without it inheriting any values from the default PYTHONPATH set in my shell (zsh).
System Information: macOS: Sonoma 14.6.1, Visual Studio Code: 1.94.0, Python Extension: v2024.16.1, Shell: zsh
Steps I’ve Taken:
- Created a
dev.envfile in my workspace. - Added the following line in
dev.envto set the PYTHONPATH:
PYTHONPATH="/Users/me/project/utils" - Referenced this file in my .code-workspace file as follows:
"python.envFile": "${workspaceFolder}/dev.env"
Problem: The PYTHONPATH is being modified instead of being set entirely re-defined by the value in the dev.env file.
It starts with the path I defined in dev.env, but it also appends the default PYTHONPATH from my shell. But I need it to replace the PYTHONPATH instead of modifying it.
Additional Attempt: I tried to reset the PYTHONPATH using the following config definition:
"terminal.integrated.env.linux": {
"PYTHONPATH": null
}
I tried this config in config files/setting below:
~/Library/Application Support/Code/User/settings.json${workspaceFolder}my_workspace.code-workspace
But this doesn't work either.
Expected Result: I want to ensure that Visual Studio Code uses only the PYTHONPATH specified in the dev.env file, without inheriting or appending values from the shell environment.
Any idea what else I can do? THX
code .