当我使用 easy_install 或 buildout 安装 PIL 时,它会以这样的方式安装,我必须执行“import Image”,而不是“from PIL import Image”。
但是,如果我执行“apt-get install python-imaging”或使用“pip -E test_pil install PIL”,一切正常。
以下是我如何尝试使用 virtualenv 安装 PIL 的示例:
# virtualenv --no-site-packages test_pil
# test_pil/bin/easy_install PIL
# test_pil/bin/python
Python 2.5.1 (r251:54863, Feb 6 2009, 19:02:12)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PIL
我明白了,easy_install 将 PIL 打包到 Egg 中,而 PIP 没有。buildbot 也一样,它使用鸡蛋。
如何使用 easy_install 或 buildout 正确安装 PIL?