在Python3.8上安装Matplotlib时出错

2024-09-24 22:29:51 发布

您现在位置:Python中文网/ 问答频道 /正文

解决方法:在我的Mac上安装Xcode会安装Matplotlib的所有缺失依赖项,因此我能够通过终端成功地安装Matplotlib。

我目前有Python2.7和Python3.8(通过Python.org网站)在我的Mac OS X Catalina上。我已经通过终端成功地安装了Numpy,并且通过终端在python2.7上安装了Matplotlib,但是当我通过终端安装Matplotlib时,总是得到两个错误代码。我试着通过终端使用不同的输入变量,我在我的在线研究中做了故障排除,但是没有用。在

输入:

pip3 install matplotlib

输出(错误1):

^{pr2}$

输出(错误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.

Tags: installsrcapi终端includematplotliblibrarycode
2条回答

Installed matplotlib on python 2.7

matplotlib的当前版本要求Python>;=3.6,因此这可能是您的挑战之一。但我认为第一个错误是问题所在——看起来你缺少了你所需要的第三方依赖关系。你可以在这里买到: https://matplotlib.org/3.1.1/users/installing.html#building-on-macos

如果不起作用,可以随意将输出粘贴到注释中。在

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

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

相关问题 更多 >