使用virtualenv或buildout安装PIL的问题

发布于 2021-01-29 16:01:28

当我使用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?

关注者
0
被浏览
41
1 个回答
  • 面试哥
    面试哥 2021-01-29
    为面试而生,有面试问题,就找面试哥。

    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即可完成。:-)显然,等待原包修复还没有回报。



知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看