mad*_*mad 2 python ubuntu pip upgrade ubuntu-20.04
每次尝试在 Python 3 中安装软件包时,我都会遇到以下问题:
WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command
Run Code Online (Sandbox Code Playgroud)
我尝试按如下方式执行升级 pip 命令,并显示以下警告:
$ pip3 install --upgrade pip
Collecting pip
Using cached pip-20.3.1-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Successfully installed pip-20.3.1
WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command
Run Code Online (Sandbox Code Playgroud)
我尝试了另一种方式,但出现了同样的错误:
$ /usr/bin/python3 -m pip install --upgrade pip
Collecting pip
Using cached pip-20.3.1-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Successfully installed pip-20.3.1
WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command
Run Code Online (Sandbox Code Playgroud)
我也尝试了以下建议来解决这个问题,下载包并要求 pip 直接从 .tar.gz 文件安装:
$sudo python3 -m pip install /home/me/Downloads/pip-20.3.1.tar.gz
[sudo] password for me:
Processing /home/me/Downloads/pip-20.3.1.tar.gz
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: pip
Building wheel for pip (PEP 517) ... done
Created wheel for pip: filename=pip-20.3.1-py2.py3-none-any.whl size=1518515 sha256=36207044a2b9042728f3cd0f971569217f4e2e9c68c84adbf5c42617e08b9d3c
Stored in directory: /root/.cache/pip/wheels/0e/09/b2/4673e6d2eee911dbbeaeeba8e68eebb9719b1b3ba25ad93e2c
Successfully built pip
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-20.3.1
Run Code Online (Sandbox Code Playgroud)
同样,同样的错误发生:
$pip3 install pydot
Collecting pydot
Using cached pydot-1.4.1-py2.py3-none-any.whl (19 kB)
Collecting pyparsing>=2.1.4
Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Installing collected packages: pyparsing, pydot
Successfully installed pydot-1.4.1 pyparsing-2.4.7
WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
Run Code Online (Sandbox Code Playgroud)
我的 Python 版本是:
$python --version
Python 3.7.9
$python3 --version
Python 3.8.5
Run Code Online (Sandbox Code Playgroud)
我的 PATH 变量链接以下目录:
$echo $PATH
/home/me/.local/bin:/home/me/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?为了将正确的 python 版本链接到 pip upgrade 命令,我是否应该向我的 PATH 变量添加一些内容?或者还有其他事情要做?
小智 7
只需使用 sudo 进行 pip3 升级。我认为您将 python2 和 python3 安装与您的 sudo 调用混淆了。刚刚测试并在 pip3 上给了我正确的版本:
$ sudo pip3 install --upgrade pip
Collecting pip
Downloading pip-20.3.1-py2.py3-none-any.whl (1.5 MB)
|????????????????????????????????| 1.5 MB 2.6 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-20.3.1
$ pip3 --version
pip 20.3.1 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
Run Code Online (Sandbox Code Playgroud)
在 KDE Neon (Ubuntu 20.04) 上测试。还要确保您没有在用户安装的某处安装其他版本的 pip。这些很容易在 apt 和 python 安装的用户位置之间混淆。
| 归档时间: |
|
| 查看次数: |
10810 次 |
| 最近记录: |