I have a similar issue on MacOS.
In the standard terminal:
$ python -V
Python 3.9.7
$ python3 -V
Python 3.9.7
$ /opt/anaconda3/bin/python -V
Python 3.9.7
All good.
However, in the VSCode terminal (in base
conda env):
$ python -V
Python 2.7.10
$ python3 -V
Python 3.6.4
$ /opt/anaconda3/bin/python -V
Python 3.9.7 # this is the one I want by default
In VSCode I set the paths for Anaconda and Python interpreters in the settings (screenshot):
Python: Conda Path
: /Users/username/opt/anaconda3/bin/conda
Python: Default Interpreter Path
: /Users/username/opt/anaconda3/bin/python
My .bash_profile
(notice I commented the paths for older python versions):
# Setting PATH for Python 3.5
# The original version is saved in .bash_profile.pysave
#PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
#export PATH
# MacPorts Installer addition on 2017-05-11_at_15:09:46: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.
# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
#PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
#export PATH
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/username/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/username/opt/anaconda3/etc/profile.d/conda.sh" ]; then
. "/Users/username/opt/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/Users/username/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
Also, when I try conda list
(in VSCode, conda base
env) I get
python 3.9.7 h88f2d9e_1
which is correct, but when running
python3 -c "import sys; print(sys.version)"
I get
3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)
which is not what I'm looking for.