我有一个ubuntu20 ,自带的 python3 解释器版本是3.8 ,然而我通过 sudo pip install python3.9
装置了一个 python3.9 而后我想给 python3.9 装置一个 pip 包管理器,如果通过 sudo apt install python3-pip
命令装置 pip 的话,是默认给 python3.8 装置的。
要验证我说的真实性,你能够在终端输出
pip -V
pip -V pip 21.2.4 from /home/bot/.local/lib/python3.8/site-packages/pip (python 3.8)
所以,这个时候,先卸载通过 apt 包管理器装置的 pip
sudo apt purge python3-pip
步骤一:
运行 curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
➜ ~ cd Downloads ➜ Downloads curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 1911k 100 1911k 0 0 1864k 0 0:00:01 0:00:01 --:--:-- 1864k
步骤二:
运行 python3.9 get-pip.py
命令
➜ Downloads python3.9 get-pip.py Defaulting to user installation because normal site-packages is not writeableLooking in indexes: https://pypi.tuna.tsinghua.edu.cn/simpleCollecting pip Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ca/31/b88ef447d595963c01060998cb329251648acf4a067721b0452c45527eb8/pip-21.2.4-py3-none-any.whl (1.6 MB)Installing collected packages: pipSuccessfully installed pip-21.2.4
步骤三:
运行 pip -V
命令
➜ Downloads pip -Vpip 21.2.4 from /home/bot/.local/lib/python3.9/site-packages/pip (python 3.9)
参考教程
多版本Python装置pip及pip版本治理终极教程