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.

VS Code unable to select Python virtualenv

See original GitHub issue

@ideologysec commented on Mon Apr 01 2019

macOS 10.14.4 VS Code 1.32.3 Python Extension 2019.3.6215

$ brew install python3
$ /usr/local/bin/python3 --version
Python 3.7.2
$ mkvirtualenv --python=/usr/local/bin/python3 --always-copy vscode
$ workon vscode
$ python --version
Python 3.7.2
  • Attempt to select Python interpreter in VS Code.
  • Success!
  • Python 3.7.2.
  • I can pip install packages in the virtualenv in Terminal or the builtin VS Code terminal, everything is hunky dory.

Then, sometime later:

$ brew upgrade
==> Upgrading 1 outdated package:
python 3.7.2_2 -> 3.7.3
==> Upgrading python
==> Downloading https://homebrew.bintray.com/bottles/python-3.7.3.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring python-3.7.3.mojave.bottle.tar.gz
==> /usr/local/Cellar/python/3.7.3/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/
==> /usr/local/Cellar/python/3.7.3/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/
==> /usr/local/Cellar/python/3.7.3/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/
==> Caveats
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python/libexec/bin

If you need Homebrew's Python 2.7 run
  brew install python@2

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
==> Summary
🍺  /usr/local/Cellar/python/3.7.3: 3,867 files, 59.8MB
Removing: /usr/local/Cellar/python/3.7.2_2... (8,464 files, 118.4MB)
Removing: /Users/user/Library/Caches/Homebrew/python--wheel--0.33.0.tar.gz... (18.3KB)
Removing: /Users/user/Library/Caches/Homebrew/python--3.7.2.tgz... (21.8MB)
Removing: /Users/user/Library/Caches/Homebrew/python--pip--19.0.2.tar.gz... (1.3MB)

which is all well and good! but: VS Code is no longer happy about the virtual environment. “Select Python Interpreter” even though I specified copy all files, even though I can workon vscode and that brings up the old 3.7.2 python virtualenv, all packages still installed,

VS Code refuses to use the old virtualenv. Even manually specifying the interpreter in the user settings.json and the workspace settings.json file, VS Code keeps yelling about “Select Python Interpreter.” It seems to have stopped believing that the virtualenv is valid.

configured not recognized

How do I get VS Code to keep using virtualenvs I create after I upgrade my homebrew python version? This is really annoying; I don’t want to keep recreating virtualenvs every time python updates (nor do I want to lock my homebrew system python from upgrading).

Per the documentation at https://code.visualstudio.com/docs/python/environments#_where-the-extension-looks-for-environments

If you have any problems with VS Code recognizing a virtual environment, please file an issue in the documentation repository so we can help determine the cause.

I am having trouble getting VS Code to recognize a virtual environment. Please help me determine the cause. 😃


@gregvanl commented on Mon Apr 01 2019

@JoshuaPartlow You may need to loop in the feature team to help investigate @DonJayamanne @brettcannon

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ideologyseccommented, Apr 1, 2019

weirdly, it recognizes that pylint is installed, all of the python packages I imported in my scripts, etc. it just won’t stop nagging about selecting a python interpreter.

0reactions
brettcannoncommented, Jan 8, 2020

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on then we will be happy to re-open this issue to pick up where we left off.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code: Python Interpreter can't find my venv - Stack Overflow
I have my venv folder on my root project folder. When I try to set the Python Interpreter, it shows me only the...
Read more >
Using Python environments in VS Code
From within VS Code, you can create non-global environments, using virtual environments or Anaconda, by opening the Command Palette (Ctrl+Shift+P), start typing ...
Read more >
What to do if Visual Studio Code can't find your virtual ...
Next, bringing up the Command Palette (by clicking View — Command Palette in the menu or by pressing CMD-Shift-P on Mac) and select...
Read more >
I can't select the Interpreter in Visual Studio Code
It seems that VS Code Editor can't find your python executable. Check if it's installed where VS Code thinks it's installed.
Read more >
How to work with VS Code and Virtual Environments in Python
Create a Project Environment ... Then run Terminal: Create New Terminal (Ctrl+Shift+`)) from the Command Palette, that opens a new python terminal ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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