如何在 Mac OSX 10.5.8 上为 Google App Engine 安装 PIL?

发布于 2024-10-15 12:23:20 字数 307 浏览 8 评论 0原文

我需要在本地安装 PIL 以在本地环境中测试 GAE 的图像 api。

我获取了适用于 Mac 的 PIL 1.1.6 安装程序,当我选择目标位置(安装时)时,出现错误:

You cannot install PIL 1.1.6 on this volume. 
PIL requires System Python 2.5 to install.

我在这台计算机上安装了 Python 2.5.x。

注意:

添加了赏金。我确实需要一种在我的 Mac 上本地测试图像 API 的方法。

I need to get PIL installed locally to test GAE's images api in my local environment.

I grabbed the PIL 1.1.6 installer for Mac, and when I go to select the destination (when installing), I get the error:

You cannot install PIL 1.1.6 on this volume. 
PIL requires System Python 2.5 to install.

I have Python 2.5.x on this machine.

NOTE:

Added a bounty. I am in real need of a way to test the image API locally on my Mac.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

成熟稳重的好男人 2024-10-22 12:23:20

这很简单:

  1. 安装 MacPorts
  2. 安装 Python 2.5 使用 sudo port install python25
  3. 使用 sudo port install py25-pil 安装 Pil for Python 2.5
  4. 在 Google App Engine 启动器首选项中 将 /opt/local/bin/python2.5 设置为 Python 路径 *
  5. 重新启动 Google App Engine 启动器
  6. 快乐编码

* 请确保用 ENTER 确认它,否则它将不会持续

That's quite easy:

  1. Install MacPorts
  2. Install Python 2.5 with sudo port install python25
  3. Install Pil for Python 2.5 with sudo port install py25-pil
  4. In the Google App Engine launcher Preferences set /opt/local/bin/python2.5 as Python Path *
  5. Restart the Google App Engine launcher
  6. Happy coding

* be sure to confirm it with an ENTER or it will not persist

溺ぐ爱和你が 2024-10-22 12:23:20

我将安装 homebrew,并使用它来安装 python2.7(pip 的要求)与自制软件一起正常工作),然后使用 pip安装 PIL。

如果您还没有安装 macports 或 fink 或其他东西,这很简单。如果这样做,您可能需要首先考虑将其删除(特别是如果它们位于 /usr/local 中)。

安装自制程序https://github.com/mxcl/homebrew/ wiki/Installation

(如果你安装了 Xcode(你需要一个编译器),你可以只使用这一行,但我建议你先阅读说明,以便了解它的作用。)

ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"

安装 python 2.7

brew install python

安装后请记住将 homebrew python 以及 homebrew bin 目录添加到 $PATH 的前面(将其放入您的 ~/.bashrc):

export PATH=/usr/local/bin:/usr/local/Cellar/python/2.7.1/bin:$PATH

安装 PIL:
(看起来我的安装是与 libjpeg 链接的,所以先安装它)

brew install jpeg
pip install pil

就这样。

I would install homebrew, and use that to install python2.7 (a requirement for pip to work properly together with homebrew) and then use pip to install PIL.

If you don't have macports or fink or something installed already, this is simple. If you do, you might want to look into removing it first (especially if they live in /usr/local).

Installing homebrew: https://github.com/mxcl/homebrew/wiki/Installation

(If you have Xcode installed (you need a compiler) you can just use this one-liner, but I recommend you read the instructions first so you understand what it does.)

ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"

Installing python 2.7:

brew install python

Just remember to add the homebrew python as well as your homebrew bin directory to the front of your $PATH after installing (put this in your ~/.bashrc):

export PATH=/usr/local/bin:/usr/local/Cellar/python/2.7.1/bin:$PATH

Installing PIL:
(it seems like my installation is linked against libjpeg, so install that first)

brew install jpeg
pip install pil

There you go.

糖粟与秋泊 2024-10-22 12:23:20

尝试一下Pillow

pip install Pillow

...就是这样。

Give Pillow a try.

pip install Pillow

... and that's it.

迷爱 2024-10-22 12:23:20

这是另一种不需要 macports 或 homebrew 等的方法......
http://cgarvey.ie/blog/archive/2010/01/27/installing-pil-on-mac-os-x-snow-leopard-for-use-in-google- app-engine/

标题中写着“雪豹”,但它在“豹”上运行良好(刚刚这样做了)。摘自文章:

  1. 下载 jpegsrc.v8c.tar.gz 或从 http://www.ijg.org 下载最新版本/files/
  2. 从该目录中提取 jpegsrc 并:

    导出 CC="gcc -arch i386"
    ./配置
    制作
    sudo make install

  3. 从 PIL 目录中下载并解压 PIL

    sudo python setup.py install

这似乎对我有用,所以希望它对其他人有帮助。

抱歉,格式有点奇怪,但我在编辑器方面遇到了一些问题。

Here is another method that does not require macports or homebrew, etc...
http://cgarvey.ie/blog/archive/2010/01/27/installing-pil-on-mac-os-x-snow-leopard-for-use-in-google-app-engine/

It says snow leopard in the title, but it works fine on leopard (just did this). Paraphrased from the article:

  1. Download jpegsrc.v8c.tar.gz or the latest from http://www.ijg.org/files/
  2. Extract jpegsrc and from within that directory:

    export CC="gcc -arch i386"
    ./configure
    make
    sudo make install

  3. Download and extract PIL and from within the PIL directory

    sudo python setup.py install

This seems to be working for me so hopefully it helps someone else.

Sorry that the formatting is a little bit weird but I'm having some trouble with the editor.

蓝眼睛不忧郁 2024-10-22 12:23:20
sudo port install py27-pil
pip install pil
sudo port install py27-pil
pip install pil
作死小能手 2024-10-22 12:23:20

正如我的评论中所述,我已经安装并测试了Python和PIL安装在这里找到 一切正常。您的错误可能与尝试使用 Python 的系统版本有关。

As stated in my comment, I have installed and tested the Python and PIL installations found here and everything works fine. Your error is likely related to trying to use the system version of Python.

幽蝶幻影 2024-10-22 12:23:20

我没有 10.5.8 来测试这个,所以 YMMV (适用于 10.6):

  1. 安装 MacPorts (Leopard 版本): http://www.macports.org/install.php
  2. 应用程序 ->公用事业 ->终端
  3. $ sudo port install python27
  4. $ sudo port install py27-pip

通过 MacPorts 或 pip 安装 PIL(以有效者为准 - 不要同时运行两者):

  • $ sudo port install py27-pil
  • $ sudo pip-2.7 install PIL

启动 Python 2.7 并测试出来:

$ python2.7
>>> import PIL
>>> PIL
<module 'PIL' from '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/__init__.pyc'>

记住,你必须输入 $ python2.7,因为 $ python 将继续加载 OS X 版本的 Python,我相信这是 2.5...

这意味着您在顶部使用 #!/usr/bin/env python 编写的任何脚本都将使用非 PIL Python 2.5。对于 PIL-Python 2.7,您必须将它们更改为 #!/opt/local/bin/python2.7。或者...

您可以通过安装 python_select 轻松更改 $ python 加载的任何 Python 版本,并忽略该头文件的疯狂:

$ sudo port install python_select
...installs stuff...
$ sudo python_select python27

现在,每当您运行 $ python 时,它都会加载 Python 2.7,而不是 OS X Python 2.5。您可以随时轻松切换回来。只需运行 $ python_select -l 即可看到 Python 的 -apple 版本。在 10.6 上:$ sudo python_select python26-apple

I don't have 10.5.8 to test this, so YMMV (works on 10.6):

  1. Install MacPorts (Leopard version): http://www.macports.org/install.php
  2. Applications -> Utilities -> Terminal
  3. $ sudo port install python27
  4. $ sudo port install py27-pip

Install PIL either via MacPorts or pip (whichever works - DON'T RUN BOTH):

  • $ sudo port install py27-pil
  • $ sudo pip-2.7 install PIL

Launch Python 2.7 and test it out:

$ python2.7
>>> import PIL
>>> PIL
<module 'PIL' from '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/__init__.pyc'>

Remember, you have to type $ python2.7, since $ python will continue to load the OS X version of Python, which is 2.5 I believe...

This means any scripts you write with #!/usr/bin/env python at the top will use the non-PIL Python 2.5. You'll have to change them to #!/opt/local/bin/python2.7 for PIL-Python 2.7. Or...

You can easily change whichever Python version $ python loads, and ignore that header madness, by installing python_select:

$ sudo port install python_select
...installs stuff...
$ sudo python_select python27

Now, whenever you run $ python, it'll load Python 2.7, and not OS X Python 2.5. You can easily switch back anytime. Just run $ python_select -l and you'll see the -apple version of Python. On 10.6: $ sudo python_select python26-apple

凡间太子 2024-10-22 12:23:20

我已经安装了 python2.7 和 PIL 很长时间(使用 MacPorts),并且我已经在非应用程序引擎工作中成功使用它们。 App Engine 无法加载它并记录以下消息:

无法初始化图像 API;您可能缺少 Python“PIL”模块。

受到 @DaveGallagher 上面关于 MacPorts 安装到 /opt/local/... 的评论的启发,我意识到我没有运行正确的 python。在“Google App Engine Launcher”中的“首选项...”中,我将“Python Path”更改为

/opt/local/bin/python2.7

现在,当我运行时,它会找到 PIL 并且图像服务可以工作。

附注我正在运行 GAE 启动器 1.8.2.978。

I've had python2.7 and PIL installed for a long time (using MacPorts) and I've been using them successfully in non-app-engine work. App Engine failed to load it and logged the following message:

Could not initialize images API; you are likely missing the Python "PIL" module.

Inspired by @DaveGallagher's comment above about MacPorts installing into /opt/local/..., I realized I wasn't running the right python. In "Google App Engine Launcher", in "Preferences...", I changed "Python Path" to

/opt/local/bin/python2.7

Now, when I run, it finds PIL and the images service works.

ps. i'm running GAE Launcher 1.8.2.978.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文