簡體   English   中英

在Mac OS X 10.9上使用pip安裝Python Image Library時出錯

[英]Error installing Python Image Library using pip on Mac OS X 10.9

我想使用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

我的命令行工具已安裝並且是最新的,我發現的每個提示都沒有幫助。 我該如何編譯?

編輯:我剛剛檢查過,freetype也已經通過自制軟件安裝了

而不是符號鏈接到特定版本的freetype2,執行以下操作:

ln -s /usr/local/include/freetype2 /usr/local/include/freetype

這樣可以省去每次升級freetype2時重新創建符號鏈接的麻煩。

使用macports,這個解決方案對我有用:

sudo port install freetype
sudo ln -s /opt/local/include/freetype2 /opt/local/include/freetype

然后重新運行PIL構建過程。

我用這個符號鏈接解決了這個問題:

ln -s /usr/local/Cellar/freetype/2.5.1/include/freetype2 /usr/local/include/freetype

我已經通過自制軟件安裝了freetype。

這是由freetype> = 2.1.5的標頭更改引起的。 PIL沒有使用正確的文檔方式來包含freetype標頭,這導致構建失敗,因為freetype最終刪除了包含標頭的長期不贊成的方式。 這個問題記錄在http://freetype.sourceforge.net/freetype2/docs/tutorial/step1.html的頂部:

注意:從FreeType 2.1.6開始,不再支持舊的頭文件包含方案。 這意味着如果您執行以下操作,現在會出現錯誤:

#include <freetype / freetype.h>
#include <freetype / ftglyph.h>

請將此問題上游問題發送給PIL的開發人員,並建議他們使用包含freetype標頭的文檔化方法:

#include <ft2build.h>
#include FT_ERRORS_H

經過多次嘗試,我解決了在沒有freetype支持的情況下編譯PIL的問題。 為此,我只是使用brew unlink freetype從我的$ PATH brew unlink freetype ,然后, pip install PIL==1.1.7

我只是解決了這個使用中描述的步驟 #1的答案。 似乎這是Xcode在異常位置安裝freetype的錯誤。

使用Pillow修復此問題“for real”:

您可以在哪里報告問題並及時查看問題:

在我的OSx中,我在/opt/local/include/freetype2找到了.h文件。 所以,我輸入

sudo ln -s /opt/local/include/freetype2/ /usr/local/include/freetype

有用

也許最好的方法是將/opt/local/include到你的clang的include路徑中。

osx約塞米蒂,這對我有用:

(的virtualenv)

$ ln -s /opt/local/include/freetype2/ /usr/local/include/freetype2
$ pip install pil==1.1.7 --allow-external pil --allow-unverified pil

我正在使用Arch Linux並遇到了這個問題。 在我的情況下,必須從https://pypi.python.org/pypi/Pillow/2.2.1#downloads手動下載並解壓縮zip文件。 然后我編輯的文件_imagingft.c以改變從包括路徑freetype/fterrors.hfterrors.h因為沒有freetype子目錄/usr/include/freetype2其中fterrors.h位於。 最后python setup.py install工作正常。

編輯:我應該提到這是安裝Pillow的解決方案,而不是PIL,但Pillow只是PIL的一個分支,它可能仍然適用於有這個問題的其他人。

如果你仍然在尋找像我讀完這個和其他谷歌搜索后的答案,你可能有興趣看到這個:

警告

Pillow> = 2.1.0不再支持“import _imaging”。 請使用“從PIL.Image導入核心作為_imaging”。

這里開始

當你讀到這篇文章時,頁面可能已經改變,但文本至少仍然在這里。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM