question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Select a Python Interpreter without modifying the workspace's settings.json

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:74
  • Comments:58 (19 by maintainers)

github_iconTop GitHub Comments

15reactions
brettcannoncommented, Jul 10, 2018

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Settings Reference for Python - Visual Studio Code
Python settings reference. The Python Extension for Visual Studio Code is highly configurable. This page describes the key settings you can work with....
Read more >
selected python interpreter is not written in user/workspace ...
When i modify some settings usually they should be recorded in the user setting. If i open my setting in json format ,...
Read more >
Selecting a python interpreter doesn't update settings.json
Manage -> Settings, Choose Workspace, click the button Open Settings(JSON) at the top right corner. This will generate a folder called .vscode ...
Read more >
VS Code editor removing pythonPath from workspace/settings ...
Select a Python Interpreter without modifying the workspace's settings.json. opened 06:34PM - 10 Jul 18 UTC. Tiedye. Be default, a ...
Read more >
Python in Visual Studio Code – July 2021 Release
Selecting a Python interpreter no longer modifies workspace settings ... Previously, selecting or changing a Python interpreter with the Python ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found