2

I have been using settings.json for a while now to share some project settings accross my different machines (which happen to be Linux, macOS and Windows). One of the settings I use is "python.pythonPath", which points to a interpreter inside the .venv created by the Poetry tool. Since Windows and linux-based operating system paths differ for virtualenvs, I need to set an environment variable with the proper path, e.g.: CLAYMEMOIRS_INTERPRETER.

I started noticing a problem where, whenever I launch visual studio code, my:

{ 
    ...
    "python.pythonPath" : "${env:CLAYMEMOIRS_INTERPRETER}" 
}

Gets automatically replaced with:

{ 
    ...
    "python.pythonPath" : "c:\\GitHub\\claymemoirs\\.venv\\Scripts\\python.exe"
}

Which is the value of my environment variable. Anyone knows how I can prevent this behaviour? I did not do any updates or changed any plugins.

1 Answer 1

13

The problem persists, but newer releases indicate python.pythonPath is being deprecated in favor of python.defaultInterpreterPath. See here.

One of the reasons for deprecation is the questioned problem.

With the new python.defaultInterpreterPath set in the workspace settings file (.vscode/settings.json) you can use environment variables to set the project .venv path in a OS independant manner "${workspaceFolder}${env:CLAYMEMOIRS_INTERPRETER}". When someone from the team loads opens the project's folder in VSCode, the interpreter will appear on the selectlist, allowing developers to select the project interpreter without messing with other people's interpreters and, without changing the workspace path.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.