如何使用 pip 安装 matplotlib

问题描述 投票:0回答:1

如何使用 pip 安装 matplotlib。我尝试使用

pip install
或从源代码安装 顺便说一句,我有 python 3.9 beta 版本

git clone [email protected]:matplotlib/matplotlib.git
cd matplotlib
python -mpip install .

但我收到以下错误

$pip install matplotlib
Collecting matplotlib
  Using cached matplotlib-3.3.2.tar.gz (37.9 MB)
    ERROR: Command errored out with exit status 1:
     command: /Users/a/.pyenv/versions/3.9.0b5/bin/python3.9 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/k0/3v16x2k52tdf00j6tpm7wffc0000gp/T/pip-install-vq_esy_g/matplotlib/setup.py'"'"'; __file__='"'"'/private/var/folders/k0/3v16x2k52tdf00j6tpm7wffc0000gp/T/pip-install-vq_esy_g/matplotlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/k0/3v16x2k52tdf00j6tpm7wffc0000gp/T/pip-pip-egg-info-ny9shc_k
         cwd: /private/var/folders/k0/3v16x2k52tdf00j6tpm7wffc0000gp/T/pip-install-vq_esy_g/matplotlib/
    Complete output (63 lines):
    WARNING: The wheel package is not available.

    Edit setup.cfg to change the build options; suppress output with --quiet.

    BUILDING MATPLOTLIB
      matplotlib: yes [3.3.2]
          python: yes [3.9.0b5 (default, Oct  2 2020, 00:38:55)  [Clang 11.0.3
                      (clang-1103.0.32.29)]]
        platform: yes [darwin]
     sample_data: yes [installing]
           tests: no  [skipping due to configuration]
          macosx: yes [installing]

    running egg_info
...
      File "/private/var/folders/k0/3v16x2k52tdf00j6tpm7wffc0000gp/T/pip-install-vq_esy_g/matplotlib/setupext.py", line 469, in add_numpy_flags
        import numpy as np
      File "/private/var/folders/k0/3v16x2k52tdf00j6tpm7wffc0000gp/T/pip-install-vq_esy_g/matplotlib/.eggs/numpy-1.19.2-py3.9-macosx-10.15-x86_64.egg/numpy/__init__.py", line 286, in <module>
        raise RuntimeError(msg)
    RuntimeError: Polyfit sanity test emitted a warning, most likely due to using a buggy Accelerate backend. If you compiled yourself, see site.cfg.example for information. Otherwise report this to the vendor that provided NumPy.
    RankWarning: Polyfit may be poorly conditioned

    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
python-3.x matplotlib pip
1个回答
0
投票

由于您的Python版本是3.9,您可以使用pip3安装matplotlib

pip3 install matplotlib

你也可以尝试一下

python3 -m pip3 install -U matplotlib

编辑

您可能没有正确安装设置工具,请尝试:

pip install --upgrade setuptools

然后

pip install matplotlib

© www.soinside.com 2019 - 2024. All rights reserved.