繁体   English   中英

Mac OS X 10.9 后无法安装 PIL

[英]Can't install PIL after Mac OS X 10.9

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

所以我尝试执行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

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

以下为我工作:

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

更新:

但Will提供了更多正确的解决方案。

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

打开你的终端并执行:

xcode-select --install

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

对我有帮助! os x 10.9

pip install pillow

但! pip安装后......

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

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

xcode-select --install

然后重新安装枕头

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
    --------------------------------------------------------------------

适合我(OS X Yosemite 10.10.2 - Python 2.7.9):

xcode-select --install
sudo pip install pillow

试试看它:

from PIL import Image
image = Image.open("file.jpg")
image.show()

这是我做的,有些步骤可能不仅仅是PIL,但我需要libpng和其他人:

1)运行xcode install,使用此命令或从应用商店下载更新:

xcode-select --install

1b)添加命令行工具可选工具,在Mountain Lion中这是xcode下载页面上的一个选项,但现在您必须注册您的苹果ID并从以下网址下载: https//developer.apple.com/downloads/

寻找Xcode的命令行工具(OS X Mavericks)

2)安装python所需的一切(使用brew),我相信你也可以使用端口:

brew install readline sqlite gdbm
brew install python --universal --framework 
brew install libpng jpeg freetype

如果需要,取消链接/重新链接,即升级。

3)安装Pip和所需的模块:

easy_install pip 
sudo pip install setuptools --no-use-wheel --upgrade

4)最后这没有错误:

sudo pip install Pillow

更新 11/04/14:PIL回购不再接收更新或支持,因此应使用Pillow。 以下现已弃用,所以坚持使用枕头。

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

更新 (旧):安装Pillow(PIL fork)同样适用,应该提及它在大多数情况下很快成为PIL的替代品。 而不是在步骤4中安装pip,而是运行它:

sudo pip install Pillow

希望这有助于某人!

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

你必须单独安装它们,因为它们现在不属于xcode中的软件包:

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

没有那些为我工作..我一直收到:

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

所以我找到了解决以下解决方案的方法:

sudo export CFLAGS=-Qunused-arguments
sudo export CPPFLAGS=-Qunused-arguments
sudo pip install PIL --allow-external PIL --allow-unverified PIL

这样我就能安装了。

我遇到了类似的问题:使用clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]安装枕头失败clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future] ,安装命令行工具失败Can't install the software because it is not currently available from the Software Update server. ,甚至在手动安装命令行工具后,PIL的编译失败。

发生这种情况导致最新版本的xcode下的clang不会对未知的编译器标志发出警告,而是以硬错误停止编译。

要解决此问题,只需在尝试编译(安装pil)之前在终端上运行export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"

简单地跑

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

这是我在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

您可以使用Homebrew来安装http://brew.sh

brew tap Homebrew/python
brew install pillow

确保在xcode上安装了命令行工具。 然后执行:

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

我有以下错误

building 'PIL._imagingft' extension
_imagingft.c:62:10: fatal error: 'freetype/fterrors.h' file not found

#include <freetype/fterrors.h>

         ^

1 error generated.

error: command 'cc' failed with exit status 1

对此的解决方案是将freetype2符号链接到freetype,这解决了这个问题。

我不想安装XCode(我不使用它),我不愿意使用Application目录。 我已经从这篇文章中的许多答案中得到了解释,以下两个步骤适用于10.9.5:

sudo easy_install pip
sudo pip install pillow

我觉得奇怪的是我必须使用easy_install来安装pip。 但是在那之前(重新安装),pip并不想为我工作。

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

重用@ 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

然后

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

执行波纹管命令行。 就像Mac OS 10.9.5上的魅力一样

easy_install pip

sudo pip install setuptools --no-use-wheel --upgrade

sudo pip安装枕头

最好的,西奥

这就是我做的:

首先升级到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/

更完整的解决方案需要安装已在Apple之外构建多年的Xquartz X11子系统。 以下是我用来完成所有工作的步骤

  1. http://xquartz.macosforge.org/landing/安装XQuartz
  2. 运行sudo pip install pillow

更新到10.9之后有同样的问题并修复了错误“命令'cc'失败并退出状态1”这个:

sudo sed -i '' -e 's/-mno-fused-madd//g' /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.py

sudo rm /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.pyc

pip install pillow

由于接受的答案是正确的xcode-select --install但有些人(包括我)可能会遇到Can't install the software because it is not currently available from the Software Update server如果您正在使用测试版软件(因为我我现在正在使用Yosemite并遇到同样的问题)你需要单独获得CLT,因为它不包含在XCode中(甚至是xcode beta)转到developers.apple.com并为你的操作系统获取CLT工具;)

PS你不需要XQuartz让PIL或Pillow工作

最近从OS 10.8升级的机器 - > 10.9卡在xcrun和lipo之间的循环中。

将/ usr / bin / lipo重命名为/ usr / bin / lipo_broken

有关如何解决的更多信息,请参阅此主题:

xcrun / lipo与OS X Mavericks和XCode 4.x冻结

改为安装枕头

sudo pip install pillow
ln -s /usr/local/include/freetype2 /usr/local/include/freetype
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pil

试试这个:

ln -s /usr/local/include/freetype2 /usr/local/include/freetype
sudo pip uninstall pillow
pip install pillow

为我工作。 我在Yosemite上运行Python 2.7.9。 import PIL现在适合我。

在Mac OSC 10.10 Yosemite上安装PIL(Imaging.1.1.7)。 我在这里尝试了很多修复,但每个都遇到了麻烦。 我终于通过编辑setup.py文件解决了这个问题,这样:

TCL_ROOT =“/ opt / X11 / include”

它在_imagingtk.c的编译中传递了X11的相应包含路径,这对我来说是个问题。 改变后立即工作。

我已经从pyenv转到virtualenv ,这解决了我的问题。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM