0

Why does my python version still show version 2.7 even though I changed the interpreter in VS Code? Could someone please help me with this?

This is what happens when I search for which python.

name@Names-Air coding_bat % which python
/usr/bin/python

Name@Names-Air coding_bat % python -m venv venv
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named venv
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Mayflon50
  • 3
  • 2
  • Does this answer your question? [VSCode terminal shows incorrect python version and path, launching terminal from anaconda works perfectly](https://stackoverflow.com/questions/54582361/vscode-terminal-shows-incorrect-python-version-and-path-launching-terminal-from) – Gino Mempin Mar 01 '21 at 01:52
  • Does this answer your question? [VSCode Python version defaults to 2.7 in the integrated terminal no matter what I do](https://stackoverflow.com/q/57713465/2745495) – Gino Mempin Mar 01 '21 at 01:53
  • @Mayflon50 -Which python environment do you want to switch to? Have you tried to open a new VS Code terminal after switching the environment? – Jill Cheng Mar 02 '21 at 01:32

1 Answers1

0

In VS Code, after switching the Python environment in the lower left corner of VS Code, we need to open a new VS Code terminal (Ctrl+Shift+`), and the new terminal window will automatically enter the currently selected python environment.

For the global environment in the python environment, there will be the following situation: the VS Code terminal always uses the first python in the python environment variable by default, therefore, we can set the one that needs to be used as the first place in the system's python environment variable, and then reopen VS Code.

enter image description here

In addition, it is recommended that you use a virtual environment in VS Code,it can avoid the above situation:

enter image description here

Jill Cheng
  • 9,179
  • 1
  • 20
  • 25