2014-10-11 72 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