PIL在终端工作,但不是通过IDLE

时间:2014-10-11 15:50:17

标签: python macos pillow

我正在尝试使用Pillow。我已按照本网站上的安装说明操作:  http://www.pythonforbeginners.com/gui/how-to-use-pillow

当我在终端窗口中输入以下内容时:

$ 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
>>> 

它没有给我任何错误,所以假设链接的网站是正确的,这意味着枕头已正确安装。 但是,当我尝试使用Python IDLE中的PIL库时,如下所示:

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,Mavericks

1 个答案:

答案 0 :(得分:2)

您的系统上至少安装了两个 Python;默认系统提供的2.7和Python 3.4。

您的pip命令与Python 2.7绑定;您可以使用以下版本运行IDLE版本:

/usr/bin/idle

或者您可以使用以下命令将Pillow安装到Python 3.4中:

python3.4 -m pip install Pillow