MAC 安装 python3和pip3

之前把 Anaconda 删除后 不得不重新下载 python3pip3
按照网上的说法 官网下载的包卸载麻烦
但官网相对比较方便 下载之后 next…就可以了
第一次安装用的是官网的包 已经忘记到底麻烦不麻烦了
来来回回这是我第三次安装 python3 了 记录一下
emmmm我还是选择试试用 home-brew

安装 brew

终端输入:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装完后检查下

brew doctor  

输出:“Your system is ready to brew”表示安装成功

提示: 安装 brew 很慢 下载完成可以改一下国内源地址

比较详细的解释 https://zhuanlan.zhihu.com/p/59805070

cd ~
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >> brew_install

打开 brew_install
在这里插入图片描述
修改BREW_REPO

# BREW_REPO="https://github.com/Homebrew/brew"
BREW_REPO="git://mirrors.ustc.edu.cn/brew.git"

修改保存后 执行以下

mkdir -p /usr/local/Homebrew/Library/Taps/homebrew/
cd /usr/local/Homebrew/Library/Taps/homebrew
git clone https://mirrors.ustc.edu.cn/homebrew-core.git

配置完成会在终端看到 brew help 显示帮助信息 则说明安装成功

查看源

# 查看brew镜像源
git -C "$(brew --repo)" remote -v
# 查看homebrew-core镜像源
git -C "$(brew --repo homebrew/core)" remote -v
# 查看homebrew-cask镜像源(需要安装后才能查看)
git -C "$(brew --repo homebrew/cask)" remote -v 

如果是https://github.com/Homebrew/brew.git的源 则需要进行修改

# 修改brew镜像源
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 修改homebrew-core镜像源
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 修改homebrew-cask镜像源(需要安装后才能修改)
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
# 更新
brew update

安装python3

查找python3

brew search python3

安装python3

brew install python3

在这里插入图片描述
python3 --version 查看版本

惊喜的发现用 brew 安装 python3 会连 pip3 一起安装
所以就不需要另外再安装 pip3 了

发布了41 篇原创文章 · 获赞 2 · 访问量 1836

猜你喜欢

转载自blog.csdn.net/weixin_43883485/article/details/105208546