使用virtualenv或buildout安装PIL的问题

亚历山大·阿捷缅科(Alexander Artemenko):

当我使用easy_install或buildout安装PIL时,其安装方式必须是“导入映像”,而不是“从PIL导入映像”。

但是,如果我执行“ 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?

马丁·彼得斯(Martijn Pieters):

pypi上打包的PIL版本(由作者提供)与setuptools不兼容,因此不是easy_installable。人们在其他地方创建了easy_installable版本。当前,您需要指定一个查找链接URL并使用pip获得一个好的包:

pip install --no-index -f http://dist.plone.org/thirdparty/ -U PIL

通过pip install与一起使用--no-index可以避免发现PIL的PyPI(非固定)原件的风险。如果要使用easy_install,则必须使用直接链接到更正版本的源tarball。easy_install仍然顽固地使用find-links URL上的PyPI链接:

easy_install http://dist.plone.org/thirdparty/PIL-1.1.7.tar.gz

要将PIL包含在扩展中,请使用相同的版本引脚指定egg或使用“版本”部分:

[buildout]
parts =
find-links =
    http://dist.plone.org/thirdparty/
eggs =
    PIL
versions = versions

[versions]
PIL = 1.1.7

2011年3月修改:解决包装问题的修补程序现已合并到PIL的开发树中,因此此解决方法可能很快就会过时。

编辑2013年2月:只需使用Pillow即可完成。:-)显然,等待原包修复还没有回报。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章