在Mavericks上安装Pillow/PIL

18 投票
5 回答
9048 浏览
提问于 2025-04-17 21:50

我在用pip或者easy_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.3/include/freetype2 -I/private/var/folders/c_/r7sp373509jdb6_1xmmzvl9c0000gn/T/pip_build_tills13/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: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]

clang: note: this will be a hard error (cannot be downgraded to a warning) in the future

error: command 'cc' failed with exit status 1

我看过所有关于符号链接的解决办法,也安装了命令行工具,但似乎都没用。我总是会遇到那个错误。

5 个回答

1

这些解决方案对我都没用。最后我在 这篇帖子 的帮助下成功安装了:

我在用最新的Xcode和操作系统更新构建MySQLdb时也遇到了同样的问题。这里有一个解决办法,就是去掉Python安装中的一个标志。

在这个路径下:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.py,有几个地方设置了 -mno-fused-madd 这个标志。如果你编辑这个文件,把所有关于这个标志的内容删掉,你的编译应该就能成功了。你还需要删除对应的 _sysconfigdata.pyc 文件——至少在我的系统上,这个文件没有自动重建。注意,做这些修改需要管理员权限。

5

除了@jussi提到的,我还需要打开终端并执行以下操作:

    sudo bash
    export CFLAGS=-Qunused-arguments
    export CPPFLAGS=-Qunused-arguments

只有这样我才能正确运行 'pip install pillow'。

如果我不使用超级用户权限来运行这个命令,就会出现以下错误:

    error: could not create '/Library/Python/2.7/site-packages/PIL': Permission denied

我正在使用OSX 10.9.2,并且安装了2014年3月的命令行工具。如果安装Homebrew有影响的话,我也是有的。

5

可以去看看 brew,网址是 http://brew.sh

brew tap Homebrew/python
brew install pillow
13

在终端里运行这个命令:

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


更多信息:

Xcode 5.1自带的编译器会把不认识的参数当成错误。

我们是在告诉它忽略这些“错误”。

来源: http://bruteforce.gr/bypassing-clang-error-unknown-argument.html

58

我用以下方法解决了这个问题。这可能和今天更新的Mavericks命令行工具有关。在执行pip install之前,试着在终端中添加以下内容:

export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments

撰写回答