[英]Error installing Python Image Library using pip on Mac OS X 10.9
I want to install PIL on Mavericks using pip but get this error. 我想使用pip在Mavericks上安装PIL,但是会出现此错误。
_imagingft.c:73:10: fatal error: 'freetype/fterrors.h' file not found
#include <freetype/fterrors.h>
^
1 error generated.
error: command 'cc' failed with exit status 1
My Command Line Tools are installed and up to date and every hint I found didn't help. 我的命令行工具已安装并且是最新的,我发现的每个提示都没有帮助。 How can I get this to compile?
我该如何编译?
EDIT: I just checked, freetype is also already installed via homebrew 编辑:我刚刚检查过,freetype也已经通过自制软件安装了
Instead of symlinking to a specific version of freetype2, do this: 而不是符号链接到特定版本的freetype2,执行以下操作:
ln -s /usr/local/include/freetype2 /usr/local/include/freetype
This saves you the trouble of recreating the symlink whenever you upgrade freetype2. 这样可以省去每次升级freetype2时重新创建符号链接的麻烦。
With macports, the solution that worked for me: 使用macports,这个解决方案对我有用:
sudo port install freetype
sudo ln -s /opt/local/include/freetype2 /opt/local/include/freetype
And then re-run the PIL build process. 然后重新运行PIL构建过程。
I've solved this problem with this symlink: 我用这个符号链接解决了这个问题:
ln -s /usr/local/Cellar/freetype/2.5.1/include/freetype2 /usr/local/include/freetype
I have freetype already installed via homebrew too. 我已经通过自制软件安装了freetype。
This is caused by a change in the headers of freetype >= 2.1.5. 这是由freetype> = 2.1.5的标头更改引起的。 PIL is not using the correct documented way to include the freetype headers, which causes the build to fail now that freetype finally removed the long-deprecated way of including the headers.
PIL没有使用正确的文档方式来包含freetype标头,这导致构建失败,因为freetype最终删除了包含标头的长期不赞成的方式。 This problem is documented right at the top of http://freetype.sourceforge.net/freetype2/docs/tutorial/step1.html :
这个问题记录在http://freetype.sourceforge.net/freetype2/docs/tutorial/step1.html的顶部:
NOTE: Starting with FreeType 2.1.6, the old header file inclusion scheme is no longer supported.
注意:从FreeType 2.1.6开始,不再支持旧的头文件包含方案。 This means that you now get an error if you do something like the following:
这意味着如果您执行以下操作,现在会出现错误:
#include <freetype/freetype.h>
#include <freetype / freetype.h>
#include <freetype/ftglyph.h>#include <freetype / ftglyph.h>
Please take this problem upstream to the developers of PIL and advise them to use the documented way of including freetype headers: 请将此问题上游问题发送给PIL的开发人员,并建议他们使用包含freetype标头的文档化方法:
#include <ft2build.h>
#include FT_ERRORS_H
After many attempts, I solved this problem compiling the PIL without freetype support. 经过多次尝试,我解决了在没有freetype支持的情况下编译PIL的问题。 To do that, I simply unlinked from my $PATH using
brew unlink freetype
and then, pip install PIL==1.1.7
. 为此,我只是使用
brew unlink freetype
从我的$ PATH brew unlink freetype
,然后, pip install PIL==1.1.7
。
Use Pillow where this issue is fixed "for real": 使用Pillow修复此问题“for real”:
And where you can report issues and see them addressed in a timely fashion: 您可以在哪里报告问题并及时查看问题:
In my OSx, I found the .h
file in /opt/local/include/freetype2
direcoty. 在我的OSx中,我在
/opt/local/include/freetype2
找到了.h
文件。 So, I type 所以,我输入
sudo ln -s /opt/local/include/freetype2/ /usr/local/include/freetype
it works 有用
Maybe the best way is to add /opt/local/include
to your clang's include path. 也许最好的方法是将
/opt/local/include
到你的clang的include路径中。
osx yosemite, this worked for me: osx约塞米蒂,这对我有用:
(virtualenv) (的virtualenv)
$ ln -s /opt/local/include/freetype2/ /usr/local/include/freetype2
$ pip install pil==1.1.7 --allow-external pil --allow-unverified pil
I'm using Arch Linux and had this issue. 我正在使用Arch Linux并遇到了这个问题。 In my case had to manually download and unpack the zip file from https://pypi.python.org/pypi/Pillow/2.2.1#downloads .
在我的情况下,必须从https://pypi.python.org/pypi/Pillow/2.2.1#downloads手动下载并解压缩zip文件。 I then edited the file
_imagingft.c
to change the include path from freetype/fterrors.h
to fterrors.h
as there was no freetype
subdirectory of /usr/include/freetype2
where fterrors.h
was located. 然后我编辑的文件
_imagingft.c
以改变从包括路径freetype/fterrors.h
到fterrors.h
因为没有freetype
子目录/usr/include/freetype2
其中fterrors.h
位于。 Finally python setup.py install
worked fine. 最后
python setup.py install
工作正常。
Edit: I should mention this was the solution for installing Pillow, not PIL, but Pillow is just a fork of PIL and it may still be applicable to others with this issue. 编辑:我应该提到这是安装Pillow的解决方案,而不是PIL,但Pillow只是PIL的一个分支,它可能仍然适用于有这个问题的其他人。
If you're still looking for answers like I was after reading this and other googling, you may be interested to see this: 如果你仍然在寻找像我读完这个和其他谷歌搜索后的答案,你可能有兴趣看到这个:
Warning 警告
Pillow >= 2.1.0 no longer supports “import _imaging”. Pillow> = 2.1.0不再支持“import _imaging”。 Please use “from PIL.Image import core as _imaging” instead.
请使用“从PIL.Image导入核心作为_imaging”。
By the time you read this, the page will probably have changed, but the text will be still here at least. 当你读到这篇文章时,页面可能已经改变,但文本至少仍然在这里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.