为什么 pip 无法在 ubuntu 20.04 lts 上干净升级?

为什么 pip 无法在 ubuntu 20.04 lts 上干净升级?

pip upgrade 不起作用,显示已升级版本仍然显示旧版本

root@ubuntu:~# pip install --upgrade pip
Collecting pip
  Downloading pip-22.0.3-py3-none-any.whl (2.1 MB)
     |████████████████████████████████| 2.1 MB 11.9 MB/s 
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.0.2
    Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
    Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-22.0.3

root@ubuntu:~# pip -V
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

root@ubuntu:~# pip install --upgrade pip
Collecting pip
  Using cached pip-22.0.3-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.0.2
    Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
    Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-22.0.3

root@ubuntu:~# pip -V
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

这是 python/pip 的位置

root@ubuntu:~# which pip
/usr/local/bin/pip
root@ubuntu:~# which pip3
/usr/local/bin/pip3
root@ubuntu:~# which python
/usr/bin/python
root@ubuntu:~# which python3
/usr/bin/python3
root@ubuntu:~# python3 -V
Python 3.8.10
root@ubuntu:~# python -V
Python 3.8.10
root@ubuntu:~# pip3 -V
pip 22.0.3 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
root@ubuntu:~# pip -V
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

我将把 pip 干净地指向 pip3,就像我之前做的那样apt install python-is-python3

有没有类似的包裹apt install pip-is-pip3

我试图避免自己手动创建符号链接

答案1

目前基本上就是这样,但如果有人找到类似的非手动方法,apt install python-is-python3请发帖

root@ubuntu:~# rm -rf /usr/local/bin/pip
root@ubuntu:~# ln -s /usr/local/bin/pip3 /usr/local/bin/pip

root@ubuntu:~# rm -rf /usr/lib/python3/dist-packages/pip
root@ubuntu:~# ln -s /usr/local/lib/python3.8/dist-packages/pip /usr/lib/python3/dist-packages/pip

root@ubuntu:~# pip -V
pip 22.0.3 from /usr/lib/python3/dist-packages/pip (python 3.8)

相关内容