安装python2 的pip
pip -V pip 21.2.3 from /Library/Python/3.8/site-packages/pip (python 3.8)
pip3 -V pip 21.2.3 from /Library/Python/3.8/site-packages/pip (python 3.8)
pip 和 pip3 指向的实际都是python3,但现在有一段老的python2代码需要调试,如何为python2重新安装pip呢?
curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py
但这个脚本已经停止了对python2对支持,最低支持3.6。
应该用以下方法:
curl -o get-pip.py https://bootstrap.pypa.io/pip/2.7/get-pip.py
sudo python2 get-pip.py
成功安装python2版本的pip
pip -V pip 20.3.4 from /Library/Python/2.7/site-packages/pip (python 2.7)
20.3.4 这是支持python 2 的最新也是最后一个pip版本, 见官方文档:https://pip.pypa.io/en/latest/development/release-process/#:~:text=pip%2020.3%20was%20the%20last%20version%20of%20pip%20that%20supported%20Python%202.
参考:
https://stackoverflow.com/questions/65866417/pip-install-failing-on-python2/65866547#65866547