我目前在我的 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.