在OSX Mountain Lion上为Google App Engine安装PIL

1 投票
1 回答
628 浏览
提问于 2025-04-17 14:29

我知道网上有很多关于这个问题的讨论,包括Stack Overflow、论坛和博客,但我还是遇到了同样的问题。我想安装PIL,以便在应用引擎的图像API中使用它。在这个API概述中,谷歌建议从pythonmac.org安装。

当我尝试安装那里提供的dmg文件时,它告诉我需要将Python 2.5安装为系统Python。稍微搜索了一下这个错误,我找到了这个Stack Overflow的问题:如何在Mac OSX 10.5.8上为Google App Engine安装PIL?。在这个问题的第一个回答中,我按照步骤1安装了macports。然后,步骤2让我运行sudo port install python25

但是我遇到了以下错误:

Error: org.macports.activate for port expat returned: Image error: /opt/local/bin/xmlwf already exists and does not belong to a registered port.  Unable to activate port expat. Use 'port -f activate expat' to force the activation.
Error: Failed to install expat
Please see the log file for port expat for details:
/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_textproc_expat/expat/main.log
Error: The following dependencies were not installed: gettext expat libiconv ncurses libedit openssl zlib python_select sqlite3
To report a bug, follow the instructions in the guide:
    http://guide.macports.org/#project.tickets
Error: Processing of port python25 failed

想查看macports的完整输出,可以去这个pastebin

当这个方法不奏效时,我又搜索了一下,找到了这篇博客。我按照建议安装了libjpeg。接下来的步骤是:

  1. http://effbot.org/downloads/Imaging-1.1.7.tar.gz下载PIL。(如果已经安装了PIL,请先卸载。)

  2. 在解压后的文件夹中: python setup.py build --force sudo python setup.py install

但是当我尝试运行python setup.py build --force时,我又遇到了这个错误:

_imaging.c:3017: warning: initialization from incompatible pointer type
_imaging.c:3077: warning: initialization from incompatible pointer type
lipo: can't figure out the architecture type of: /var/folders/q_/wgr019b53rx9b2lr3y7867bm0000gn/T//ccJY6hPI.out
error: command 'gcc-4.2' failed with exit status 1

想查看完整输出,可以去这个pastebin

我还尝试了一些其他的方法,等我有时间会把那些补充上,但我想尽快把这个发出来。谢谢大家的帮助。

1 个回答

0

一种解决办法是使用 Pillow。Plone团队对这些麻烦感到厌烦,于是他们从PIL项目中分支出来了。

Pillow是PIL的一个替代品,安装和使用起来简单得多,不会让人感到头疼。

撰写回答