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.
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:
- Created 4 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top GitHub Comments
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.
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.