系统更新后brew和pip命令均显示command not found
无奈之下只好重新安装
Homebrew
方法一:
执行命令:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
可能会出现如下报错或者速度极慢:
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
这是由于 http://raw.githubusercontent.com 访问不稳定引起的。
方法二(更高效快速稳定):
/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)"
该脚本用了中科大镜像加速访问,仅修改仓库地址部分,不会产生安全隐患。 关于中科大所提供的 Homebrew 镜像服务 https://lug.ustc.edu.cn/wiki/mirrors/help/brew.git
配置Homebrew
Homebrew在安装软件时非常慢。为了提升安装速度,需要更改 Homebrew 的安装源,将其替换成国内镜像。
这里用的是由中科大负责托管维护的 Homebrew 镜像。其中,前两个为必须配置的项目,后两个可按需配置。
(1)替换 brew.git:
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
(2)替换homebrew-core.git :
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
(3)替换homebrew-cask.git :
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
(4)替换homebrew-bottles:
首先要先区分你的mac用哪种终端工具,如果是 bash,则执行:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
若是 zsh,则执行:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
pip
使用pip3时一直收到提示:
WARNING: You are using pip version 20.1.1; however, version 21.3.1 is available.
You should consider upgrading via the '/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -m pip install --upgrade pip' command.
说明我的pip版本版本太低,需要升级。
虽然这里提示是用'pip install --upgrade pip'升级,但是不能这样输入,要输入:
pip3 install --upgrade pip
很顺利就升级到最新版本啦