I'm running VS Code 1.33.1 on macOS Sierra (10.12.6). When I run a simple Python program like the following, VS Code uses Python 2.7 as installed on my Mac rather than Python 3 which I installed using Homebrew.
# show-python-version.py
import sys
print(sys.version)
Here's the output as displayed in the VS Code Output window:
[Running] python -u "/Users/smith/Documents/Programming/Python/Examples/show-python-version.py"
2.7.15 (default, May 1 2018, 16:44:37)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]
[Done] exited with code=0 in 0.032 seconds
As you can see, I'm getting version 2.7.15 because it's calling "python" instead of "python3", but I don't know how to get it to use python3. Here are all the things I've done to try to fix this problem:
I've ensure that none of my virtual environments that use Python 2.7 are running when I issue the "code ." command in the Examples directory.
I installed Python 3 using Homebrew so I opened the Command Pallette (shift + cmd + p), typed in "Python: Select Interpreter", and confirmed that it's using my Homebrew version: current: /usr/local/bin/python3.
I checked VS Code's Settings, searched for "python.pythonPath" and confirmed that it's the same as the interpreter path shown in step 2 above.
I also examined the file Examples/.vscode/settings.json to confirm the interpreter path there too:
{ "python.pythonPath": "/usr/local/bin/python3" }
I've restarted VS Code to no avail.
I have these extensions installed:
esbenp.prettier-vscode@1.8.1
formulahendry.code-runner@0.9.8
fosshaas.fontsize-shortcuts@1.5.0
ms-python.python@2019.3.6558
tht13.python@0.2.3
vmsynkov.colonize@2.2.2
vscodevim.vim@1.4.0
It's may be related to my path which looks like the following since both python and python3 are in /usr/local/bin:
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:....
What am I doing wrong?