Mac Python中安装版本不对

mac安装各个版本的python
使用版本管理器就行,纯属之前闲的

位置:/Library/Frameworks/Python.framework/Versions

其中有个current文件,是其中一个的替身,就是当前python的哪个版本

使用python的官方安装包是可以切换的(重新安装),他们不给个脚本?非要手动(没试过):大概就是右键目标版本的文件夹,制作替身,然后去/bin:/usr/local/bin,把python3的替身文件换一下

  1. 终端 :Python3 -V,结果不符合预期

首先修改了~/.zshrc

添加 export PATH=HOME/bin:/usr/local/bin:PATH

然后ok了

ps: /etc/paths 文件包含mac默认的一些路径,其中有/usr/local/bin,但是重新在.zshrc文件添加后,/usr/local/bin放在了前面,覆盖了其他的路径配置。

echo $PATH
发现各个版本的python路径

/Users/yc/bin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin

  1. 接着找,发现配置文件 ~/.zprofile,存在几个版本的路径,应该是安装时加上的(你还能再隐蔽点吗?),注释掉,重新打开终端

echo $PATH

python的路径消失

  1. 接着:在更新pip版本时,提示:

WARNING: The scripts pip, pip3 and pip3.10 are installed in '/Library/Frameworks/Python.framework/Versions/3.10/bin' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.