1. python安装
- 安装pyenv
brew install pyenv
//设置环境
vi ~/.bash_profile
//内容如下:
export PYENV_ROOT=/usr/local/var/pyenv
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
//执行生效
source ~/.bash_profile
- 根据系统,安装对应python。 下载地址
//比如查看最新的是3.10.1
pyenv install 3.10.1
//查看本地版本
python --version
python3 --version
pyenv --version
pyenv versions
卸载python3.10.1
sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.10
cd /Applications
sudo rm -rf Python 3.7
cd /usr/local/bin/
ls -l /usr/local/bin
rm Python3*
vi ~/.bash_profile //删掉3.10相关路径
source ~/.bash_profile
- 安装pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
//python2.x
sudo python get-pip.py
//python3.x
sudo python3 get-pip.py