Mac 安装 python3 配置 环境变量

523 阅读1分钟

macOS 自带 python2.7,到官网下载 python3 的 macOS 版本,并安装。 安装完毕 python3 以后,敲入命令获得安装路径:

which python3

我的安装路径为:

/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7

将这个路径配入环境变量:

vim ~/.bash_profile

在文件的最后一行输入下面代码,保存并重启电脑:

alias python="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7"

命令行敲入:

python

输出如下信息表明 python3 环境配置成功:

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.