如何在MacOS 10.9上安装PIL?

2 投票
2 回答
769 浏览
提问于 2025-04-17 22:38

我在Macosx 10.9.2上尝试安装PIL库时,遇到了以下错误,应该怎么安装呢?

$: sudo pip install pillow

cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DHAVE_LIBJPEG -DHAVE_LIBZ -DHAVE_LIBTIFF -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -I/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/Cellar/freetype/2.5.2/include/freetype2 -I/private/tmp/pip_build_root/pillow/libImaging -I/System/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/local/include -I/usr/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.9-intel-2.7/_imaging.o

clang: 错误:未知参数:'-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]

clang: 注意:这将来会成为一个严重错误(不能降级为警告)

错误:命令'cc'失败,退出状态为1

2 个回答

0

这是因为OS10.9更换了它的cc编译器,所以'cc'无法编译某些Python库。我试着通过把我的cc编译器换成旧版本的gcc来解决这个问题。首先,你需要安装brew。

$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

然后安装gcc-4.2。

$ sudo brew install apple-gcc42

接下来,删除当前的cc。它只是一个指向clang的符号链接,所以你不需要备份它。

$ sudo rm -f /usr/bin/cc

然后创建一个新的符号链接,把cc指向gcc-4.2。

$ sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 /usr/bin/cc

测试一下你是否成功更改了它。

$ ls -l /usr/bin | grep cc

如果显示

$ cc -> /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2

那就说明你成功更改了你的cc编译器。这样你就可以安装像PIL或pillow这样的Python库了。

2

下面这行代码对我有帮助。

sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pillow

撰写回答