Mac使用HomeBrew安装Python3.*并设为默认版本

前言:本文简单介绍Mac下使用HomeBrew安装Python 3.*版本并设置为默认值

一、安装

1、首先查看Mac自带的python,可以看到是2.7.10的版本

python
image

2、查看python3的安装包

brew search python3
image

3、安装python3

brew install python3

可以看到python3的实际安装目录是/usr/local/Cellar/python3/3.6.2

4、打开配置文件并写入python的外部环境变量

open ~/.bash_profile

 export PATH=${PATH}:/usr/local/Cellar/python3/3.6.2/bin

5、重命名python

alias python="/usr/local/Cellar/python3/3.6.2/bin/python3.6"

6、让配置文件生效

source ~/.bash_profile

7、使用python命令查看

python
image

8、如果没有设置成功的话使用which python3查看此时Python3的位置是否正确,若不正确重复步骤4、5、6

which python3
image

原文地址:https://blog.csdn.net/NancyLiu0/article/details/81781809

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容