欢迎光临散文网 会员登陆 & 注册

为macOS 12.3以上版本安装python2

2023-02-05 18:07 作者:CI知名气人鸽手_HiEo  | 我要投稿

要在macOS 12.3以上安装python2,你需要:

良好的网络

极佳的耐心

富余的硬盘空间

首先,你需要安装Xcode

直接前往appstore搜索安装即可

然后安装homebrew

此处给出tuna镜像站的链接

https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/

打开终端,跟随页面上的教程执行即可。

太长不看版:

xcode-select --install

export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"

export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"

export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"

git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install

/bin/bash brew-install/install.sh

rm -rf brew-install

上述命令需一条条执行,等当前命令执行完毕后方可继续

到这里,homebrew就算安装完了。如若需要,可以跟随tuna镜像站的教程继续替换镜像源,会对下载速度有较大提升

之后,参照轶哥的教程执行即可

链接:https://www.wyr.me/post/658

太长不看版:

brew install pyenv

pyenv install 2.7.18

export PATH="$(pyenv root)/shims:${PATH}"

pyenv global 2.7.18

echo 'PATH=$(pyenv root)/shims:$PATH' >> ~/.zshrc


上述命令执行完毕后,前往终端输入:

python --version

并执行

若输出2.7.18,那么恭喜你,安装成功


疑难杂症

1⃣️重启后若失效,再次依次执行下列代码即可

export PATH="$(pyenv root)/shims:${PATH}"

pyenv global 2.7.18

echo 'PATH=$(pyenv root)/shims:$PATH' >> ~/.zshrc

2⃣️待补充...



参考链接

https://www.wyr.me/post/658

https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/

为macOS 12.3以上版本安装python2的评论 (共 条)

分享到微博请遵守国家法律