Mac 升级Python2.7, 3.7版本共存

安装Python 3.7
1、下载地址如下:https://www.python.org/downloads/

2、点击下载好的pkg文件进行安装

3、安装完成之后,python 3.70的默认安装路径如下:/Library/Frameworks/Python.framework/Versions/3.7

在terminal里运行open /.bash_profile,打开/.bash_profile,直接修改文件即可

1、修改方式

添加:

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

2、重启一下Terminal,使修改后的文件生效。

Python 2.7与Python 3.7版本的切换
使用Python 2.7时,直接将~/.bash_profile文件中3.7的版本注释掉,即
#aliaspython="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7"

使用Python 3.7时,直接将~/.bash_profile文件中3.7的版本打开,即
aliaspython="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7"

验证
在终端中直接 输入 python -V,显示版本号为3.7

系统2.7版本目录 /System/Library/Frameworks/Python.framework/Versions/

tips:

如果提示 ssl 证书 error
进入mac 应用程序 找到Python 安装包 双击Install Certificates.command

你可能感兴趣的:(工具)