19

我需要在本地安裝PIL以在我的本地環境中測試GAE的圖像API。如何在Mac OSX 10.5.8上爲Google App Engine安裝PIL?

我抓起PIL 1.1.6安裝程序的Mac,當我去選擇目標(安裝時),我得到的錯誤:

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

我有這臺機器上的Python 2.5.X。

注意:

增加了一個賞金。我真的需要一種方法來在我的Mac上本地測試圖像API。

+0

它是你自己安裝的還是系統版本的python?你有沒有嘗試這些PIL和Python版本:http://pythonmac.org/packages/py25-fat/index.html。也看到這個http://stackoverflow.com/questions/1774825/unable-to-use-pil-after-installing-using-pythononmac-org-package-mac-os-leopard – Benjamin 2011-02-01 21:35:42

+0

+1 - 有類似的困境試圖安裝PIL在Mac OS X上,希望有一個很好的解決方案。 – ocodo 2011-02-01 21:35:56

+0

好問題。我不確定。我該如何檢查? 「系統Python」指的是與Mac OSX捆綁的版本? – 2011-02-01 21:37:07

回答

20

這是相當容易:

  1. 安裝MacPorts
  2. 安裝的Python 2.5sudo port install python25
  3. 安裝弼爲Python 2.5sudo port install py25-pil
  4. 在谷歌應用程序引擎啓動首選項設置/opt/local/bin/python2.5 as Python Path*
  5. 重新啓動谷歌應用程序引擎啓動
  6. 快樂編碼

*一定要與確認它的ENTER或不會持續

1

正如我的評論所述,我已經安裝並測試了Python和PIL安裝found here,並且一切正常。您的錯誤可能與嘗試使用系統版本的Python有關。

0

我沒有10.5.8測試這一點,所以因人而異(適用於10.6):

  1. 安裝MacPorts的(豹版):http://www.macports.org/install.php
  2. 應用程序 - >工具 - >終端
  3. $ sudo的港口安裝python27
  4. $ sudo的港口安裝py27點子

無論是通過的MacPorts或PIP安裝PIL(取工程 - 不要同時運行):

  • $ sudo的港口安裝py27弼
  • $ sudo的PIP-2.7安裝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將繼續加載Python的OS X版本,這是2.5我相信...

這意味着您在頂部使用#!/usr/bin/env python編寫的任何腳本都將使用非PIL Python 2.5。您必須將它們更改爲PIL-Python 2.7的#!/opt/local/bin/python2.7。還是......

您可以輕鬆地更改任何一個Python版本$ python負荷,而忽略頭瘋狂,通過安裝python_select:

$ 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

5

我會安裝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 

只記得安裝(把這個在您的~/.bashrc)後,爲你的自制bin目錄添加自制蟒蛇,以及您$PATH的面前:

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

安裝PIL: (好像我安裝與libjpeg聯繫在一起,所以首先安裝)

brew install jpeg 
pip install pil 

那你去吧。

3

Pillow一試。

pip install Pillow 

......就是這樣。

2

這裏是不需要的MacPorts或自制程序,等其他方法...... 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的」
    的./configure
    使
    須藤使安裝

  3. 下載並從PIL目錄中提取PIL

    sudo python setup.py install

這似乎是爲我工作,所以希望它可以幫助別人。

對不起,格式有點奇怪,但我在編輯器中遇到了一些麻煩。

2
sudo port install py27-pil 
pip install pil 
0

我已經安裝了python2.7和PIL很長時間(使用MacPorts),我一直在非應用程序引擎工作中成功地使用它們。應用程序引擎無法加載它,並記錄了以下消息:

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

靈感來自@ DaveGallagher的評論上述有關安裝到的MacPorts /選擇/本地/ ... ...,我意識到我沒有運行對蟒蛇。在「谷歌應用程序引擎啓動器」,在「首選項...」,我改成「Python的路徑」,以

/opt/local/bin/python2.7

現在,當我運行,它找到PIL和圖像服務的工作原理。

ps。我正在運行GAE Launcher 1.8.2.978。