I just installed VS Code, Python (version 3.7.5 released on Oct.15, 2019) on MacOS.
So I run python --version
on my VS Code Terminal, the result showed Python 2.7.11
.
Shouldn't it be 3.7.5?
I just installed VS Code, Python (version 3.7.5 released on Oct.15, 2019) on MacOS.
So I run python --version
on my VS Code Terminal, the result showed Python 2.7.11
.
Shouldn't it be 3.7.5?
You need to select the Python version you want to use for VS Code. See here
I would also recommend setting up virtual environments if you plan to do a significant amount of Python work.
As per the comment discussion, you have two versions of python installed, 2.7.11 and 3.7.5.
To use 3.7.5, you need to execute it as python3
. python3 --version
gives the expected output.
In case you want to run python --version
instead of python3 --version
.You can use pyenv to set a global version of python. Once it’s done, you can just run python --version
, and the result will be the version of your global python.
Pyenv only deals with the python installed by pyenv itself, so if you want to use it, you may reinstall the specific version you want via pyenv.
Pyenv is also a tool to manage your virtual environment, and I guess you can kill two birds with one stone. There are two friendly articles explaining the virtual environment and pyenv respectively.
Installing Python version 3+ does not overwrite Python 2. So you may have both versions configured on your system. To check the version of each, use:
python2 --version
python3 --version
To identify if one is defaulting higher than the other, you can use the following to trace the path of both versions.
which python2
which python3
Depending on how close the paths are to your root, one may be defaulting to the other.