Select a Python Interpreter without modifying the workspace's settings.json
See original GitHub issueBe 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
.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:74
- Comments:58 (19 by maintainers)
@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 setpython.pythonPath
to${workspaceFolder}/.venv
to be consistent within your project without any hard-coded, absolute paths.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.