Python——python3-mac环境安装

1、mac自带一个2.7版本的python

MacBookPro:python wuxi$ which python /usr/bin/python

查看 python 版本

MacBookPro:python wuxi$ python --version Python 2.7.10

2、mac 安装python3版本

brew install python3

MacBookPro:bin wuxi$ which python3 /usr/local/bin/python3

python3 软链接

python3 -> ../Cellar/python/3.7.2_1/bin/python3 

python3 -> ../Frameworks/Python.framework/Versions/3.7/bin/python3

查看最新python版本

MacBookPro:site-packages wuxi$ python3 --version Python 3.7.2

第三方包安装位置site-packages

/usr/local/lib/python3.7/site-packages

运行python3

exit()退出

MacBookPro:~ wuxi$ python3
Python 3.7.2 (default, Jan 13 2019, 12:51:54) 
[Clang 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

3、配置环境变量

将python命令替换成python3

export Python_HOME=/usr/local/Cellar/python/3.7.2_1
// 全局命令行
export PATH=$Python_HOME/bin:$PATH
// python 指向python3
alias python="/usr/local/Cellar/python/3.7.2_1/bin/python3"
// pip 指向pip3
alias pip="/usr/local/Cellar/python/3.7.2_1/bin/pip3"

source /etc/profile

打开终端 执行 python ,修改成功

MacBookPro:bin wuxi$ python
Python 3.7.2 (default, Jan 13 2019, 12:51:54) 
[Clang 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print(100 + 200 + 300)
600
>>> print(100 + 300)
400
>>> exit()

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值