赞
踩
Mac自带的2.7版本将于2020年停止支持
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
确保已经安装Xcode(或者Xcode命令行工具CommandLineTools)
brew search python
brew install python3.x
第一行命令查看并选择python版本,看好要安装的版本,再使用第二行命令安装即可。
python -V
神奇的事情发生了,你发现你的py版本还是2.7,这是因为python默认多版本可共存机制,而macOS默认版本指向的是原装的2.7版本。
来源 | python安装路径 |
---|---|
系统默认 | /System/Library/Frameworks/Python.framework/Versions/2.7 |
brew安装 | /usr/local/Cellar |
官网pkg安装 | /Library/Frameworks/Python.framework/Versions/2.7 |
open ~/.bash_profile
打开~/.bash_profile# Setting PATH for Python 3.9
# The original version is saved in .bash_profile.pysave
PATH="/usr/local/Cellar/python@3.9/3.9.4/bin:${PATH}"
export PATH
alias python="/usr/local/Cellar/python@3.9/3.9.4/bin/python3.9"
【一般情况下,在安装py3.x版本后系统会自动生成bash_profile文件,但是我在修改bash_profile文件时,发现并没有bash_profile文件存在,于是touch了一个新的文件,并进行了修改后续操作】
source .bash_profile
更新文件**【经过一番折腾】**重新查看Python版本,发现版本已更新
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。