Skip to content

Latest commit

 

History

History
57 lines (39 loc) · 1.33 KB

install_python_3_and_virtualenv_on_macos.md

File metadata and controls

57 lines (39 loc) · 1.33 KB

安装python3

xcode-select --install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile
brew install python3

官方Python 3安装会在用户目录~/.bash_profile添加:

PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH

所以,默认就可以找到 python3。注意,这个解析器也要在VS Code中设置

安装virtualenv

pip3 install virtualenv

可能需要翻墙才能安装

并且可能提示升级pip版本

pip3 install --upgrade pip
$ pip --version
pip 18.1 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)
$ python3 --version
Python 3.7.0

$ which python3
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3

参考