我的 "python" 命令和 "which python" 指向不同的 python 版本

My "python" command and "which python" point to different python versions

我正在使用 Anaconda,发现所有不同环境的“python”命令都指向一个 python /home/ya/anaconda3/bin/python,即 python 3.8。我的基础环境使用 python 3.8,我安装了 myenv 和 python 3.7 的环境。但是,我发现当我在 myenv 中输入 python 时,它总是使用 3.8 而不是 3.7.

除非您使用的是 zsh(它是内置的),否则 which 只能检查 PATH。它对函数或别名一无所知。

使用 type python 作为更准确的方式来查看当您的 shell 为 bash 时 python 将 运行 做什么。