1)pip3 安装 matplotlib 时出错 2)pip 无法导入 main

1)pip3 安装 matplotlib 时出错 2)pip 无法导入 main

我输入了pip3 install matplotlib但出现以下错误。

Collecting matplotlib
  Using cached https://files.pythonhosted.org/packages/12/d1/7b12cd79c791348cb0c78ce6e7d16bd72992f13c9f1e8e43d2725a6d8adf/matplotlib-3.1.1.tar.gz
    Complete output from command python setup.py egg_info:

    Beginning with Matplotlib 3.1, Python 3.6 or above is required.

    This may be due to an out of date pip.

    Make sure you have pip >= 9.0.1.


    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-mf5yly3l/matplotlib/
You are using pip version 8.1.1, however version 19.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

然后我尝试升级,pip install --upgrade pip但运行 pip3 install matplotlib 现在出现错误

Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
ImportError: cannot import name 'main'

答案1

您需要使用 python3 -m pip install 而不是 pip install

sudo python3 -m pip uninstall pip && sudo apt install python3-pip
--reinstall

相关内容