mac 安装 python3
mac自带多个低版本的python
查看python版本
python --version
Python 2.7.16
python3 --version
Python 3.7.3
安装homebrew (已安装的略过)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
或者
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
安装python3最新3.8.5
brew install python
python会安装到
/usr/local/Cellar目录下
mac系统自带python在
/usr/bin/ 目录下包含python3 的(貌似3.7.3版本)
修改默认设置为刚安装的版本
export PATH=${PATH}:/usr/local/Cellar/python@3.8/3.8.5/bin
alias python="/usr/local/Cellar/python@3.8/3.8.5/bin/python3"
alias pip="/usr/local/Cellar/python@3.8/3.8.5/bin/pip3"
此时查看版本为刚安装的版本
在终端查看python3
which python3
/usr/bin/python3
配置Sublime Text
Tools->Build System->New Build System
python3配置信息
系统自带的python3
{
"cmd": ["/usr/bin/python3", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
python3.8.5安装路径 如果你在这个路径找不到python3 替换自己的电脑的python3.8.5路径
{
"cmd": ["/usr/local/Cellar/python@3.8/3.8.5/bin/python3", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
保存文件路径默认名字随意但是必须为 .sublime-build 的文件后缀
比如 python3..sublime-build | python3.8.5..sublime-build | python3.7..sublime-build
方便区分不同版本
1.打开终端输入:python3
2.导入sys包:import sys
3.查找路径 :sys.path