美文网首页
macOS 安装 python3

macOS 安装 python3

作者: 庞贝船长 | 来源:发表于2020-12-05 11:15 被阅读0次

前言:
先下载homebrew, 再使用homebrew 下载安装 python3.

1.Homebrew 的2种安装方法

1.1 方法一

最简单,直接拉取github上的会失败,使用下面方法安装:

/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"

1.2 方法二

麻烦了点

1.2.1下载 homebrew

终端输入

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

安装完成Homebrew后,需将其所在路径插入到 PATH 环境变量的最前面,即在您所登录用户的 ~/.profile 文件末尾加上这一行:

export PATH="/usr/local/opt/python/libexec/bin:$PATH"

若出现报错: curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
原因: DNS域受污染
解决方法: 打开 https://www.ipaddress.com/ 输入访问不了的域名

image
查询之后可以获得正确的 IP 地址, 在本机的 host 文件中添加
$ sudo vi /etc/hosts

添加

199.232.68.133 raw.githubusercontent.com

2.安装 python3

$ brew install python

参考

相关文章

网友评论

      本文标题:macOS 安装 python3

      本文链接:https://www.haomeiwen.com/subject/qffgwktx.html