2014-10-11 70 views
1

我正在嘗試使用Pillow。我已經按照本網站上的安裝說明: http://www.pythonforbeginners.com/gui/how-to-use-pillowPIL在終端中工作,但不通過空閒

當我鍵入以下到我的終端窗口:

$ python 
Python 2.7.5 (default, Mar 9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> from PIL import Image 
>>> 

它不給我任何錯誤,所以假設鏈接的網站是正確的這意味着枕頭已正確安裝。 然而,當我嘗試使用PIL庫從Python IDLE,像這樣:

from PIL import Image 

Python的給出錯誤信息:

Traceback (most recent call last): 
    File "/Sample_application.py", 
line 3, in <module> 
from PIL import Image 
ImportError: No module named 'PIL' 

我在做什麼錯?我正在使用mac OSX 10.9,小牛

+0

或安裝。什麼'輸入sys; print(sys.prefix)'在任一環境中生成? – 2014-10-11 15:53:45

+0

哎呀,這可能是問題!在終端我得到2.7,通過IDLE我得到3.4。我該如何解決這個問題? – 2014-10-11 16:24:00

+0

您可能會運行'/ usr/bin/idle'來運行系統安裝的IDLE。或者使用'python3.4 -m pip install Pillow'將Pillow安裝到Python 3.4中。 – 2014-10-11 16:38:06

回答

2

您至少有兩個您系統上的Python安裝;默認的系統提供的2.7和Python 3.4。

您的pip命令綁定到Python 2.7;你可以使用該版本與空轉的版本:

/usr/bin/idle 

或者你可以安裝枕成Python 3.4:您可能正在使用帶*不同* Python版本安裝在IDLE

python3.4 -m pip install Pillow