尝试在Mac上安装matplotlib时出错

我已经下载了Python 3.7,并正在使用终端将matplotlib安装到我的Mac OS上。我尝试过:

pip3 install matplotlib

但是,我遇到以下错误:

        ERROR: Command errored out with exit status 1:
     command: /library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -u -c 'import sys,setuptools,tokenize; sys.argv[0] = '"'"'/private/var/folders/fm/gp4lphn1231f22hp_kzh82rw0000gn/T/pip-install-n_oqiwm0/matplotlib/setup.py'"'"'; __file__='"'"'/private/var/folders/fm/gp4lphn1231f22hp_kzh82rw0000gn/T/pip-install-n_oqiwm0/matplotlib/setup.py'"'"';f=getattr(tokenize,'"'"'open'"'"',open)(__file__);code=f.read().replace('"'"'\r\n'"'"','"'"'\n'"'"');f.close();exec(compile(code,__file__,'"'"'exec'"'"'))' install --record /private/var/folders/fm/gp4lphn1231f22hp_kzh82rw0000gn/T/pip-record-_jw4chgf/install-record.txt --single-version-externally-managed --compile
         cwd: /private/var/folders/fm/gp4lphn1231f22hp_kzh82rw0000gn/T/pip-install-n_oqiwm0/matplotlib/
    Complete output (506 lines):
    ================================================================================
    Edit setup.cfg to change the build options

    BUILDING MATPLOTLIB
      matplotlib: yes [3.1.1]
          python: yes [3.8.0 (v3.8.0:fa919fdf25,Oct 14 2019,10:23:27)  [Clang 6.0
                      (clang-600.0.57)]]
        platform: yes [darwin]

    OPTIONAL SUBPACKAGES
     sample_data: yes [installing]
           tests: no  [skipping due to configuration]

    OPTIONAL BACKEND EXTENSIONS
             agg: yes [installing]
           tkagg: yes [installing; run-time loading from Python Tcl/Tk]
          macosx: yes [installing,darwin]

    OPTIONAL PACKAGE DATA
            dlls: no  [skipping due to configuration]
    ...

    UPDATING build/lib.macosx-10.9-x86_64-3.8/matplotlib/_version.py
    set build/lib.macosx-10.9-x86_64-3.8/matplotlib/_version.py to '3.1.1'
    running build_ext
    building 'matplotlib.ft2font' extension
    creating build/temp.macosx-10.9-x86_64-3.8
    creating build/temp.macosx-10.9-x86_64-3.8/src
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DFREETYPE_BUILD_TYPE=system -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -D__STDC_FORMAT_MACROS=1 -Iextern/agg24-svn/include -I/library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/numpy/core/include -I/library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/checkdep_freetype2.c -o build/temp.macosx-10.9-x86_64-3.8/src/checkdep_freetype2.o
    src/checkdep_freetype2.c:1:10: fatal error: 'ft2build.h' file not found
    #include <ft2build.h>
             ^~~~~~~~~~~~
    1 error generated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -u -c 'import sys,'"'"'exec'"'"'))' install --record /private/var/folders/fm/gp4lphn1231f22hp_kzh82rw0000gn/T/pip-record-_jw4chgf/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

我不知道为什么它不会安装。我已经尝试了3.7和3.8。但是,似乎没有任何作用。

zyp0374 回答:尝试在Mac上安装matplotlib时出错

您缺少C编译器,从头开始编译Matplotlib是必需的。

通常,Matplotlib和许多其他更复杂的库以二进制形式作为 wheels 分发。

但是,您提到您正在使用Python 3.8,这是非常的最新版本。不幸的是,在为Python 3.8编写there are no wheels for the latest release of Matplotlib时。

尽管它们{em>确实存在latest pre-release version 3.2.0a1

如果您愿意试用该版本,

console.log()

或仅安装Python 3.7。

本文链接:https://www.f2er.com/3164956.html

大家都在问