枕头已安装,但属性不存在

Pillow installed, but attributes not present

所以我使用安装程序 "Pillow-3.3.0.win32-py2.7.exe" 安装了 pillow,但由于某些原因,在我导入它后 none 它的属性可用。如果我运行下面的代码

import PIL
print(dir(PIL))

会return

['PILLOW_VERSION', 'VERSION', '__builtins__', '__doc__', '__file__', 
'__name__', '__package__', '__path__', '_plugins']

如您所见,枕头的所有属性都丢失了。如果我尝试通过

之类的方式访问属性
PIL.Image.open(someImage)

会return

AttributeError: 'module' object has no attribute 'Image'

我在安装 PIL 时遇到了同样的问题。我在网上搜索过,似乎找不到任何关于为什么会这样的信息。 我该如何解决?

答案是here,

PIL's init.py is just an empty stub as is common. It won't magically import anything by itself.

When you do from PIL import Image it looks in the PIL package and finds the file Image.py and imports that. When you do PIL.Image you are actually doing an attribute lookup on the PIL module (which is just an empty stub unless you explicitly import stuff).

枕头不支持import PIL。使用 from PIL import Image.