Python Mac OS X 10.9 后无法安装 PIL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19532125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 13:59:50  来源:igfitidea点击:

Can't install PIL after Mac OS X 10.9

pythonmacospython-imaging-librarypiposx-mavericks

提问by Vincent Audebert

I've just updated my Mac OS to 10.9 and I discovered that some (all?) of my Python modules are not here anymore, especially the Image one.

我刚刚将我的 Mac OS 更新到 10.9,我发现我的一些(全部?)Python 模块不再存在,尤其是 Image 模块。

So I try to execute sudo pip install pil, but I get this error:

所以我尝试执行sudo pip install pil,但我收到此错误:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found

#      include <X11/Xlib.h>

               ^

1 error generated.

error: command 'cc' failed with exit status 1

My Xcode is up-to-date and I don't have any idea. Is it possible that PIL is not yet 10.9 compatible ?

我的 Xcode 是最新的,我不知道。PIL 是否有可能与 10.9 不兼容?

采纳答案by Dmitry Demidenko

Following worked for me:

以下为我工作:

ln -s  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11 /usr/local/include/X11
sudo pip install pil

UPDATE:

更新:

But there is more correct solution below, provided by Will.

但是下面有更正确的解决方案,由 Will 提供。

open your terminal and execute: xcode-select --install

打开终端并执行: xcode-select --install

回答by Vincent Audebert

Found the solution ... You've to symlink X11 like this ln -s /opt/X11/include/X11 /usr/local/include/X11and then sudo pip install pilshould work.

找到解决方案......你必须像这样符号链接X11 ln -s /opt/X11/include/X11 /usr/local/include/X11,然后sudo pip install pil应该可以工作。

回答by Sergey

  1. ln -s /opt/X11/include/X11 /usr/local/include/X11
  2. pip install pil without sudo
  1. ln -s /opt/X11/include/X11 /usr/local/include/X11
  2. pip install pil 没有 sudo

回答by klem4

sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11/ /usr/local/include/X11

helps for me! os x 10.9

对我有帮助!操作系统 x 10.9

pip install pillow

but! after pip install ...

但!pip安装后...

*** ZLIB (PNG/ZIP) support not available

and finally i fix it by running:

最后我通过运行来修复它:

xcode-select --install

then reinstall pillow

然后重新安装枕头

pip install pillow

PIL SETUP SUMMARY
    --------------------------------------------------------------------
    version      Pillow 2.2.1
    platform     darwin 2.7.5 (default, Aug 25 2013, 00:04:04)
                 [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
    --------------------------------------------------------------------
    --- TKINTER support available
    --- JPEG support available
    --- ZLIB (PNG/ZIP) support available
    --- TIFF G3/G4 (experimental) support available
    --- FREETYPE2 support available
    --- LITTLECMS support available
    --- WEBP support available
    --- WEBPMUX support available
    --------------------------------------------------------------------

回答by Formulka

installing command line tools fixed the issue for me

安装命令行工具为我解决了这个问题

you have to install them separately as they are not part of the packages in xcode now:

您必须单独安装它们,因为它们现在不是 xcode 中软件包的一部分:

https://developer.apple.com/downloads/index.action?=command%20line%20tools#

https://developer.apple.com/downloads/index.action?=command%20line%20tools#

回答by William Monroe

That's what I did:

这就是我所做的:

First upgrade to Xcode 5 (I am running 10.9). Then, execute the following commands in a terminal:

首先升级到 Xcode 5(我运行的是 10.9)。然后,在终端中执行以下命令:

$ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
$ ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11 usr/include/

回答by Willem

open your terminal and execute:

打开终端并执行:

xcode-select --install

xcode-select --install

回答by Dimosthenis Kontogiorgos

Reusing @DmitryDemidenko's answer that is how it worked for me:

重用@DmitryDemidenko 的答案,这对我来说是有效的:

ln -s  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11 /usr/local/include/X11

and then

进而

sudo pip install -U PIL --allow-external PIL --allow-unverified PIL

回答by jqualls

Simply run

只需运行

pip install pil --allow-external pil --allow-unverified pil

pip install pil --allow-external pil --allow-unverified pil

回答by saranpol

This my steps on mac os 10.9.1

这是我在 mac os 10.9.1 上的步骤

1. sudo su
2. easy_install pip
3. xcode-select --install
4. pip install --no-index -f http://dist.plone.org/thirdparty/ -U PIL