Python3 修改默认环境的方法

Mac 环境中既有自带的 Python2.7 也有自己安装的 Python 3.5.1,默认想用 Python3 的环境

1. 添加 Python3 的环境变量

vi ~/.bash_profile 

# Setting PATH for Python 3.5
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH 

2. 添加别名

vi ~/.bashrc

alias python="/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5" 

3. 立即生效

source .bash_profile

以上这篇Python3 修改默认环境的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持来客网。