问题
RESOLVED: Installing Xcode on my Mac installed all missing dependencies of Matplotlib, thus I was able to successfully install Matplotlib via Terminal.
I currently have Python 2.7 and Python 3.8 (downloaded the .dmg via Python.org) on my Mac OS X Catalina. I have successfully installed Numpy via Terminal, as well as Matplotlib on Python 2.7 via Terminal, but I always get two error codes when I install Matplotlib through Terminal. I've tried using different variants of inputs via terminal via troubleshooting I did in my online research, but to no avail.
Input:
pip3 install matplotlib
Output (Error #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
Output (Error #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.
回答1:
I was able to solve this by using the unnoficial packages, you can download then here and just make sure to install de requirements, you can find them on the link too, then install each package with:
pip install "SomePackage-1.0-py2.py3-none-any.whl"
回答2:
Installed matplotlib on python 2.7
The current version of matplotlib requires Python >= 3.6, so this might be part of your challenge. But I think the first error is where the issue lays - it looks like you're missing your needed 3rd party dependencies. You can get those here: https://matplotlib.org/3.1.1/users/installing.html#building-on-macos
Feel free to paste your output in a comment if that doesn't work.
来源:https://stackoverflow.com/questions/58557593/error-installing-matplotlib-on-python-3-8