You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Select a Python Interpreter without modifying the workspace's settings.json #2125
Be default, a local pipenv environemnt is searched for and if found, is marked as the python interpreter. But it also then adds a line to settings.json indicating the path for the virtual environment which can cause issues for configs shared among a team. The python.pythonPath variable will not be constant for each user working on the repo (eg "python.pythonPath": "/home/daniel/.local/share/virtualenvs/ontariofresh_backend-NQNAEc6t/bin/python", note my home directory in the path) and thus prevents the settings.json file from being committed to the remote repository.
Ideally, it would behave just as it does now, but just implicitly sets the python interpreter as the one found without explicitly writing it out to settings.json.
Environment data
VS Code version: 1.25.0
Extension version (available under the Extensions sidebar): 2018.6.0
OS and version: ubuntu 18.04
Python version (& distribution if applicable, e.g. Anaconda): 2.7.15
Type of virtual environment used (N/A | venv | virtualenv | conda | ...): pipenv
Actual behavior
The installed pipenv virtual environment is found and selected as the python interpreter and the path to that environment is added to settings.json.
Expected behavior
The installed pipenv virtual environment is found and selected as the python interpreter and the path to that environment is not added to settings.json.
Reacted by Mark Adamson, Tobias Hernstig, André Sassi, Ben MacLeod, Al Johri, Midori Kochiya, Joshua Sleeper, Nai You-Ran, Ben Cook, Samuel Ainsworth and 58 more
Reacted by Samuel Ainsworth, higstar, Sotetsu KOYAMADA, Pablo Miralles Roure, Severin Bahman and Aryan Iyappan
Daniel Whitney (@Tiedye) No problem! It was basically phrasing as "this is bad!" can be off-putting because it comes off as a demand instead of a request.
Daniel Whitney (@Tiedye) a work-around for this is to set PIPENV_VENV_IN_PROJECT and the extension will automatically pick up the .venv directory that gets created. And you can set python.pythonPath to ${workspaceFolder}/.venv to be consistent within your project without any hard-coded, absolute paths.
Reacted by Ben MacLeod, Dan Cecile, Ben Cook, Abhishek Nigam, Peter Schutt, Sandy Fraser, Kingsley Ijomah, Srinivas Neppalli, Ashley Connor, Leandro and 4 more
We can leave this issue open to consider coming up with a solution that negates the need to force you to set an environment variable (at worst we could document this for users).
As for getting personal workspace settings, I believe there is a VS Code issue on this topic so if you can find it and upvote it then that might help get it implemented.
I'm thinking of using this workaround too as I can easily roll out environment variables to all our devs. The unfortunate thing about it is that the .venv isn't in the default .gitignore in our version of GitHub Enterprise so we'll need to remember to add it to every repo. It is in the public github.com version
Brett Cannon (@brettcannon) Is that the only workaround or could you opt not to update .vscode/settings.json in some way and still use the Pipenv virtualenv's pythonPath?
It's great that VS code is working on a general fix in microsoft/vscode#15909 though. I am wondering however if it is customary for extensions to automatically update a workspace's settings? As settings.json is aimed to be shared amongst team members of a project it becomes problematic if it is updated with individual settings, such as in this issue.
Tobias Hernstig (@thernstig) I don't know if there's any customary practice that has been established by the VS Code extension community. For us we do it because there's a visible startup cost in searching for a person's environment, so writing it out short circuits that search.
Brett Cannon (@brettcannon) Part of the reason I am making that comment is because we had this same discussion for issue #265. There I referred to the issue microsoft/vscode#851 on VS Code, where bpasero (his team started VS Code when it was still called Monaco) made this comment about .vscode/settings.json
These things are workspace related settings so they are stored in the workspace folder with the intent to share them to other people (e.g. a launch configuration is typically OS and path independent).
In relation to that, I was thinking that polluting .vscode/settings.json with user-specific settings must be some kind of antipattern?
Adding specific settings to .vscode/settings.json breaks the convention of sharing workspace specific settings for projects. I think this is a huge issue for teams utilizing this feature.
Every user in our project now has to do a git checkout .vscode/settings.json everytime before commit in order to not commit their personal venv path.
SteelPhase (@SteelPhase) I didn't know about that, I guess it's still experimental. Seems like it's meant exactly for this purpose. Thanks. I'll wait until it's officially released.
Andriy Drozdyuk (@drozzy) being part of Microsoft does not mean we get to tell the VS Code team what to do 😉 . You can go to github.com/microsoft/vscode and open a feature request if you want (although I suspect one already exists so I would check first).
Hi,
A long thread so sorry if I missed an answer to this.
We have a system that is building isolated python environments (trying our hardest to specifically avoid polluting target machines with multiple python installations 😉)
Our extension, related to this just stopped working on some people as a part of the A/B testing and we are looking for a way forward.
We would just need an API (or any way) to set the interpreter path of this extension from another extension.
As of now, we have not found a way.. are we missing something?
Universally opt out of the experiment and stick with python.pythonPath
We are actually hoping to have this whole situation resolved in a release or two in a way that should make everyone happy (famous last words, I know 😉).
Hi, yeah I know these things are not easy to get done.
I forgot to upvote #16370 (I came from the "same source" 😉).
Basically, we don't care about the internals as much as the fact that we could just somehow get isolated python environments up-n-running with this extension (as pretty much every Python developer using VsCode has this one installed as it is kind of a default).
In enterprise-scale automation scenarios having the end-user or even the developer's machine "polluted" by multiple Python installations is a no-go. So not all Python environments are installed on the OS level and having a way to point a Python environment location to this extension would be a crucial thing to have.
This issue is also reproduced on this build.
After change Python Interpreter, the file settings.json is not generated in .vscode in current folder/workspace.
Activity
[-]`settings.json` is modified on startup when using pipenv[/-]brettcannon commentedon Jul 10, 2018
[I edited your ✉️ ⬆️ to come off as more 😃 and less 😠 ]
Yes, VS Code's lack of "workspace-personal" on top of a "workspace-global" config can be a problem in this situation.
Tiedye commentedon Jul 10, 2018
Ha sorry, didn't realize I was coming off as 😠
brettcannon commentedon Jul 10, 2018
Daniel Whitney (@Tiedye) No problem! It was basically phrasing as "this is bad!" can be off-putting because it comes off as a demand instead of a request.
brettcannon commentedon Jul 10, 2018
Daniel Whitney (@Tiedye) a work-around for this is to set
PIPENV_VENV_IN_PROJECTand the extension will automatically pick up the.venvdirectory that gets created. And you can setpython.pythonPathto${workspaceFolder}/.venvto be consistent within your project without any hard-coded, absolute paths.Tiedye commentedon Jul 10, 2018
Awesome! That works. Should the issue be left open? Or is this more of a vs-code issue at this point.
brettcannon commentedon Jul 11, 2018
We can leave this issue open to consider coming up with a solution that negates the need to force you to set an environment variable (at worst we could document this for users).
As for getting personal workspace settings, I believe there is a VS Code issue on this topic so if you can find it and upvote it then that might help get it implemented.
Tiedye commentedon Jul 12, 2018
microsoft/vscode#15909 for reference
mungojam commentedon Jul 19, 2018
I'm thinking of using this workaround too as I can easily roll out environment variables to all our devs. The unfortunate thing about it is that the .venv isn't in the default .gitignore in our version of GitHub Enterprise so we'll need to remember to add it to every repo. It is in the public github.com version
thernstig commentedon Jul 28, 2018
Brett Cannon (@brettcannon) Is that the only workaround or could you opt not to update .vscode/settings.json in some way and still use the Pipenv virtualenv's pythonPath?
It's great that VS code is working on a general fix in microsoft/vscode#15909 though. I am wondering however if it is customary for extensions to automatically update a workspace's settings? As settings.json is aimed to be shared amongst team members of a project it becomes problematic if it is updated with individual settings, such as in this issue.
brettcannon commentedon Jul 30, 2018
Tobias Hernstig (@thernstig) I don't know if there's any customary practice that has been established by the VS Code extension community. For us we do it because there's a visible startup cost in searching for a person's environment, so writing it out short circuits that search.
thernstig commentedon Aug 1, 2018
Brett Cannon (@brettcannon) Part of the reason I am making that comment is because we had this same discussion for issue #265. There I referred to the issue microsoft/vscode#851 on VS Code, where bpasero (his team started VS Code when it was still called Monaco) made this comment about .vscode/settings.json
In relation to that, I was thinking that polluting .vscode/settings.json with user-specific settings must be some kind of antipattern?
Adding specific settings to .vscode/settings.json breaks the convention of sharing workspace specific settings for projects. I think this is a huge issue for teams utilizing this feature.
Every user in our project now has to do a
git checkout .vscode/settings.jsoneverytime before commit in order to not commit their personal venv path.54 remaining items
drozzy commentedon Feb 18, 2021
But aren't you guys part of microsoft?
SteelPhase commentedon Feb 18, 2021
Doesn't this have a workaround using the following setting, or am I mistaken?
drozzy commentedon Feb 18, 2021
SteelPhase (@SteelPhase) I didn't know about that, I guess it's still experimental. Seems like it's meant exactly for this purpose. Thanks. I'll wait until it's officially released.
brettcannon commentedon Feb 18, 2021
Andriy Drozdyuk (@drozzy) being part of Microsoft does not mean we get to tell the VS Code team what to do 😉 . You can go to github.com/microsoft/vscode and open a feature request if you want (although I suspect one already exists so I would check first).
SteelPhase (@SteelPhase) yep, that will get you what you want for now.
kariharju commentedon Jun 3, 2021
Hi,
A long thread so sorry if I missed an answer to this.
We have a system that is building isolated python environments (trying our hardest to specifically avoid polluting target machines with multiple python installations 😉)
Our extension, related to this just stopped working on some people as a part of the A/B testing and we are looking for a way forward.
We would just need an API (or any way) to set the interpreter path of this extension from another extension.
As of now, we have not found a way.. are we missing something?
brettcannon commentedon Jun 3, 2021
Kari Harju (@kariharju) you have a couple of options:
python.pythonPathWe are actually hoping to have this whole situation resolved in a release or two in a way that should make everyone happy (famous last words, I know 😉).
kariharju commentedon Jun 8, 2021
Hi, yeah I know these things are not easy to get done.
I forgot to upvote #16370 (I came from the "same source" 😉).
Basically, we don't care about the internals as much as the fact that we could just somehow get isolated python environments up-n-running with this extension (as pretty much every Python developer using VsCode has this one installed as it is kind of a default).
In enterprise-scale automation scenarios having the end-user or even the developer's machine "polluted" by multiple Python installations is a no-go. So not all Python environments are installed on the OS level and having a way to point a Python environment location to this extension would be a crucial thing to have.
linette-zyy commentedon Jun 28, 2021
This issue is also reproduced on this build.

After change Python Interpreter, the file settings.json is not generated in .vscode in current folder/workspace.
brettcannon commentedon Jun 28, 2021
Please see #12313 (comment) for an explanation of the change we are slowly rolling out to users to address this.
Remove python.pythonPath from the settings file to match upcomming VS…
Remove python.pythonPath from the settings file to match upcomming VS…
brettcannon commentedon Jul 28, 2021
https://devblogs.microsoft.com/python/python-in-visual-studio-code-july-2021-release/#selecting-a-python-interpreter-no-longer-modifies-workspace-settings announced this feature.