運(yùn)行命令brew install pip3,結(jié)果界面一直卡在Updating Homebrew…上
解決辦法是替換brew源:
替換brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
替換homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
重置brew.git:
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
重置homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
查看當(dāng)前Homebrew 鏡像源
# brew.git鏡像源
git -C "$(brew --repo)" remote -v
# homebrew-core.git鏡像源
git -C "$(brew --repo homebrew/core)" remote -v
# homebrew-cask.git鏡像源
git -C "$(brew --repo homebrew/cask)" remote -v
國內(nèi)鏡像地址
科大真香實(shí)例:
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
if [ $SHELL = "/bin/bash" ] # 如果你的是bash
then
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/' >> ~/.bash_profile
source ~/.bash_profile
elif [ $SHELL = "/bin/zsh" ] # 如果用的shell 是zsh 的話
then
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/' >> ~/.zshrc
source ~/.zshrc
fi
brew update
如果需要恢復(fù)原有鏡像源的話(國內(nèi)鏡像源突然不能用了或版本不夠新)
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git
# 找到 ~/.bash_profile 或者 ~/.zshrc 中的HOMEBREW_BOTTLE_DOMAIN 一行刪除
brew update
如果可以了下面的就不用看了
如果不行的話可以依次嘗試以下命令
brew doctor
brew update-reset
brew update