更新时间:2023-12-04 21:45:34
Edit: From the comment to my answer by @cgohlke, this will change in PIL1.2:
支持从标准导入 命名空间[已删除]; PIL现在仅位于PIL命名空间中
the support for importing from the standard namespace [has been dropped]; PIL now lives in the PIL namespace only
我认为Django注释非常清楚:
I think the Django comment is pretty clear:
# Try to import PIL in either of the two ways it can end up installed.
PIL可以作为一个软件包安装,您可以访问其中的模块:
PIL can either be installed as a single package, and you access the modules within it:
from PIL import ImageFile as PILImageFile
或者每个模块可以分别安装:
or the modules can each be installed separately:
import ImageFile as PILImageFile
因此安装了PIL,它只是分成了各个组件模块.
So PIL is installed, it is just split up into it's component modules.
这也是中使用PIL的问题virtualenv或buildout ,@ Ignacio在评论中提到 PIL教程实际上期望以这种方式安装,第一段代码开始:
It's also the issue in The problem with installing PIL using virtualenv or buildout, and @Ignacio mentions in a comment that the PIL tutorial actually expects it to be installed this way, the very first chunk of code starts:
>>> import Image
不是from PIL import Image
.
我同意这是令人困惑的行为,但我想它是一个相对较大的程序包,因此他们可能认为不必处理额外的深度会更容易.
I agree this is confusing behavior, but I guess it's a relatively large package so they might think it's easier to not have to deal with an extra level of depth.
This seems to be the problem in Python - package installed with easy_install is not being detected (PIL 1.1.7) although only the last answerer there figured it out, the rest of the people don't know what is going on.