fir*_*ter 3 python matplotlib macos
如果已经讨论过这个话题,我提前道歉。我的情况似乎与其他情况略有不同,因此我的文件路径不同。尝试在 Mac OS X 10.8.5 上安装 matplotlib 时,返回以下错误:
pip install matplotlib
# lots of install details here...
/usr/X11/include/ft2build.h:56:10: fatal error: 'freetype/config/ftheader.h' file not found
#include <freetype/config/ftheader.h>
^
1 error generated.
error: command 'clang' failed with exit status 1
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip_build_root/matplotlib/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ohMPzS-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/tmp/pip_build_root/matplotlib
Storing debug log for failure in /Users/administrator/Library/Logs/pip.log
Run Code Online (Sandbox Code Playgroud)
我的 Homebrew 安装了以下内容:
fontconfig
gfortran
jpeg
libtiff
pkg-config
freetype
libpng
Run Code Online (Sandbox Code Playgroud)
我在 /usr/bin/python 使用 Mac 版本的 Python 2.7.2
所以我使用 Finder 来搜索 ftheader.h,它说文件位于:
/opt/X11/include/freetype2/freetype/config/ftheader.h
Run Code Online (Sandbox Code Playgroud)
我的问题是:
谢谢!
更新:
这似乎解决了问题:
sudo ln -s /usr/local/include/freetype2/ /usr/include/freetype
Run Code Online (Sandbox Code Playgroud)
这会创建一个从 /usr/include/freetype 到 /usr/local/include/freetype2/ 的符号链接(当您单击 /usr/include/freetype 时,您将被重定向到 /usr/local/include/freetype2/)。在创建符号链接之前,最好先验证系统上的第一个路径是否正确。如果第二条路径不存在,则将创建第二条路径。
创建符号链接后,我sudo pip install matplotlib再次尝试,这次它成功安装。穆乔支持这篇文章的想法!如果稍后下游出现错误,我会报告。
还值得注意的是,存在一个matplotlib 二进制文件。
我不认为更改 /usr/include 的内容(如另一个答案和其他类似线程中所建议的)一般来说不是一个好主意;那是苹果的“财产”。关于 StackOverflow 的一个类似问题,在 Homebrew 安装的上下文中,而是建议在 /usr/local/include 中链接,这更安全,但仍然可能不是一个好主意,因为 Homebrew 维护了这一点。
我认为更好的解决方案是遵循 matplotlib 安装说明并使用 setup.cfg 文件来指定不在预期位置的资源位置。要在让 pip 管理安装的同时执行此操作:
下载 mpl 源并将其解压到 DIR(例如,DIR=matplotlib-1.3.1)。
cd DIR, 将 'setup.cfg.template' 复制到 'setup.cfg',然后将目录部分编辑为如下所示(假设您已将 freetype2 安装到 /usr/local,例如,通过 Homebrew):
[directories]
# Uncomment to override the default basedir in setupext.py.
# This can be a single directory or a comma-delimited list of directories.
#basedirlist = /usr
basedirlist = /usr/local/include/freetype2/
Run Code Online (Sandbox Code Playgroud)通过以下方式就地构建 matplotlib(但不要安装它):(python setup.py build_ext在我的 MacBook Pro 上大约需要一分钟)。
从该目录中使用 pip 安装:( pip install .注意点!)。
Pip 会将其识别为 matplotlib 并适当地索引。
当我这样做时,我已经安装了 mpl 的依赖项,所以我不确定缺少其中的一些是否会使这复杂化。
| 归档时间: |
|
| 查看次数: |
3279 次 |
| 最近记录: |