我沒有10.5.8測試這一點,所以因人而異(適用於10.6):
- 安裝MacPorts的(豹版):http://www.macports.org/install.php
- 應用程序 - >工具 - >終端
- $ sudo的港口安裝python27
- $ 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
它是你自己安裝的還是系統版本的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
+1 - 有類似的困境試圖安裝PIL在Mac OS X上,希望有一個很好的解決方案。 – ocodo 2011-02-01 21:35:56
好問題。我不確定。我該如何檢查? 「系統Python」指的是與Mac OSX捆綁的版本? – 2011-02-01 21:37:07