命令 'pip install Somepackage' 不适用于 Ubuntu 20.04

The command 'pip install Somepackage' does not work on Ubuntu 20.04

我安装了 Ubuntu 20.04。 我安装了 python3.8python3-pip。 但是在执行 pip install SomePackage 时出现此错误。

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 11, in <module>
    load_entry_point('pip==7.1.0', 'console_scripts', 'pip')()
  File "/usr/local/lib/python3.8/dist-packages/pip-7.1.0-py3.8.egg/pip/__init__.py", line 217, in main
    return command.main(cmd_args)
  File "/usr/local/lib/python3.8/dist-packages/pip-7.1.0-py3.8.egg/pip/basecommand.py", line 216, in main
    with self._build_session(
  File "/usr/local/lib/python3.8/dist-packages/pip-7.1.0-py3.8.egg/pip/basecommand.py", line 68, in _build_session
    session = PipSession(
  File "/usr/local/lib/python3.8/dist-packages/pip-7.1.0-py3.8.egg/pip/download.py", line 316, in __init__
    self.headers["User-Agent"] = user_agent()
  File "/usr/local/lib/python3.8/dist-packages/pip-7.1.0-py3.8.egg/pip/download.py", line 92, in user_agent
    zip(["name", "version", "id"], platform.linux_distribution()),
AttributeError: module 'platform' has no attribute 'linux_distribution'

您正在使用 python 3.x.x。这就是你应该使用 pip3 的原因。

这样试试:

pip3 install SomePackage

如果 pip3 未加载,请使用此选项:

sudo apt install python3-pip

您也可以使用此更新:

python3 -m pip install --upgrade pip