如何在 Mac OSX 10.5.8 上为 Google App Engine 安装 PIL?
我需要在本地安装 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
这很简单:
sudo port install python25
sudo port install py25-pil
安装 Pil for Python 2.5/opt/local/bin/python2.5
设置为 Python 路径 ** 请确保用 ENTER 确认它,否则它将不会持续
That's quite easy:
sudo port install python25
sudo port install py25-pil
/opt/local/bin/python2.5
as Python Path ** be sure to confirm it with an ENTER or it will not persist
我将安装 homebrew,并使用它来安装 python2.7(
pip
的要求)与自制软件一起正常工作),然后使用pip
安装 PIL。如果您还没有安装 macports 或 fink 或其他东西,这很简单。如果这样做,您可能需要首先考虑将其删除(特别是如果它们位于
/usr/local
中)。安装自制程序:https://github.com/mxcl/homebrew/ wiki/Installation
(如果你安装了 Xcode(你需要一个编译器),你可以只使用这一行,但我建议你先阅读说明,以便了解它的作用。)
安装 python 2.7 :
安装后请记住将 homebrew python 以及 homebrew bin 目录添加到
$PATH
的前面(将其放入您的~/.bashrc
):安装 PIL:
(看起来我的安装是与
libjpeg
链接的,所以先安装它)就这样。
I would install homebrew, and use that to install python2.7 (a requirement for
pip
to work properly together with homebrew) and then usepip
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.)
Installing python 2.7:
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
):Installing PIL:
(it seems like my installation is linked against
libjpeg
, so install that first)There you go.
尝试一下Pillow。
...就是这样。
Give Pillow a try.
... and that's it.
这是另一种不需要 macports 或 homebrew 等的方法......
http://cgarvey.ie/blog/archive/2010/01/27/installing-pil-on-mac-os-x-snow-leopard-for-use-in-google- app-engine/
标题中写着“雪豹”,但它在“豹”上运行良好(刚刚这样做了)。摘自文章:
从该目录中提取 jpegsrc 并:
导出 CC="gcc -arch i386"
./配置
制作
sudo make install
从 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:
Extract jpegsrc and from within that directory:
export CC="gcc -arch i386"
./configure
make
sudo make install
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.
正如我的评论中所述,我已经安装并测试了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.
我没有 10.5.8 来测试这个,所以 YMMV (适用于 10.6):
通过 MacPorts 或 pip 安装 PIL(以有效者为准 - 不要同时运行两者):
启动 Python 2.7 并测试出来:
记住,你必须输入
$ 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 版本,并忽略该头文件的疯狂:现在,每当您运行
$ 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):
Install PIL either via MacPorts or pip (whichever works - DON'T RUN BOTH):
Launch Python 2.7 and test it out:
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: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
我已经安装了 python2.7 和 PIL 很长时间(使用 MacPorts),并且我已经在非应用程序引擎工作中成功使用它们。 App Engine 无法加载它并记录以下消息:
受到 @DaveGallagher 上面关于 MacPorts 安装到 /opt/local/... 的评论的启发,我意识到我没有运行正确的 python。在“Google App Engine Launcher”中的“首选项...”中,我将“Python Path”更改为
现在,当我运行时,它会找到 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:
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
Now, when I run, it finds PIL and the images service works.
ps. i'm running GAE Launcher 1.8.2.978.