使用 vs code 和 anaconda 路径在 mac 上设置 python 3.10 环境

Set python 3.10 environment on mac with vs code and anaconda paths

我在 python 3.7.4 上使用 vs 代码,我在 mac 上安装了 anaconda。 现在我安装了python 3.10,我可以在vs code中切换环境,但是终端仍然是3.7.4,所以我无法立即将任何库pip安装到3.10版本上。我必须如何设置 PATH 才能在我的终端中使用 3.10 作为标准安装?

我也不知道该用bash还是zsh。
Anaconda 不允许我添加 python 3.10

的环境

3.10安装是/usr/local/bin/python3

echo $PATH: /opt/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin

这些是配置文件:

cd && touch .zprofile && open .zprofile:

# Setting PATH for Python 3.8
# The original version is saved in .zprofile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH

# Setting PATH for Python 3.10
# The original version is saved in .zprofile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.10/bin:${PATH}"
export PATH

cd && touch .bash_profile && open .bash_profile:

# added by Anaconda3 2019.10 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/opt/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/opt/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

不同版本的anaconda对应不同版本的Python。当你升级Python到3.10时,anaconda也需要一个新版本。这是下载page