【问题标题】:Error Installing Matplotlib on Python 3.8在 Python 3.8 上安装 Matplotlib 时出错
【发布时间】:2019-10-25 11:22:23
【问题描述】:

我目前在我的 Mac OS X Catalina 上安装了 Python 2.7 和 Python 3.8(通过 Python.org 下载了 .dmg)。我已经通过终端成功安装了 Numpy,以及通过终端在 Python 2.7 上安装了 Matplotlib,但是当我通过终端安装 Matplotlib 时,我总是收到两个错误代码。我已经尝试通过我在在线研究中进行的故障排除,通过终端使用不同的输入变体,但无济于事。

输入:

pip3 install matplotlib

输出(错误 #1):

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/6l/48hzctr50x9gg5rv9zzc5jl40000gn/T/pip-install-k3_jyhbb/matplotlib/setup.py'"'"'; __file__='"'"'/private/var/folders/6l/48hzctr50x9gg5rv9zzc5jl40000gn/T/pip-install-k3_jyhbb/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/6l/48hzctr50x9gg5rv9zzc5jl40000gn/T/pip-record-9nz4sjf0/install-record.txt --single-version-externally-managed --compile
     cwd: /private/var/folders/6l/48hzctr50x9gg5rv9zzc5jl40000gn/T/pip-install-k3_jyhbb/matplotlib/
Complete output (509 lines):
IMPORTANT WARNING:
    pkg-config is not installed.
    matplotlib may not be able to find some of its dependencies
================================================================================
Edit setup.cfg to change the build options

输出(错误 #2):

  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, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6l/48hzctr50x9gg5rv9zzc5jl40000gn/T/pip-install-k3_jyhbb/matplotlib/setup.py'"'"'; __file__='"'"'/private/var/folders/6l/48hzctr50x9gg5rv9zzc5jl40000gn/T/pip-install-k3_jyhbb/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/6l/48hzctr50x9gg5rv9zzc5jl40000gn/T/pip-record-9nz4sjf0/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

【问题讨论】:

  • 第二个错误似乎表明您缺少ft2build 标头。我认为这是freetype 的一部分,所以我认为您将需要freetype 库来解决第二个错误。也许看到stackoverflow.com/questions/18887445/…

标签: python matplotlib terminal macos-catalina python-3.8


【解决方案1】:

我可以通过使用非官方包解决这个问题,你可以下载然后here 并确保安装 de 要求,您也可以在链接上找到它们,然后安装每个包:

pip install "SomePackage-1.0-py2.py3-none-any.whl"

【讨论】:

    【解决方案2】:

    在 python 2.7 上安装 matplotlib

    当前版本的 matplotlib 需要 Python >= 3.6,因此这可能是您面临的挑战的一部分。但我认为第一个错误是问题所在 - 看起来您缺少所需的第 3 方依赖项。你可以在这里得到那些: https://matplotlib.org/3.1.1/users/installing.html#building-on-macos

    如果这不起作用,请随时将您的输出粘贴到评论中。

    【讨论】:

      猜你喜欢
      • 2020-04-05
      • 2021-01-13
      • 2021-02-07
      • 2021-11-09
      • 1970-01-01
      • 2021-02-20
      • 2023-03-03
      • 1970-01-01
      相关资源
      最近更新 更多