簡體   English   中英

使用virtualenv或buildout安裝PIL的問題

[英]The problem with installing PIL using virtualenv or buildout

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

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仍然頑固地在查找鏈接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即可完成。 :-)顯然,等待原包裝修復還沒有收到回報。

使用枕頭:“友好的” PIL叉 :-)它提供:

  • 全面的設置工具兼容性
  • 更快的發布周期
  • 沒有與PIL不同的圖像代碼更改(即,它旨在跟蹤所有PIL圖像代碼更改,並且在不向上游報告的情況下不進行任何更改)。
  • Windows二進制文件

如果PIL確實做到了Pillow所做的事情,那么前叉就會死掉。 在此之前,我們有Pillow。

免責聲明 :我是fork的作者,Pillow的創建主要是為了使我的工作更輕松(盡管很高興看到其他人也使用它)。

編輯 :2013年3月15日發布了Pillow 2.0.0。它提供Python 3支持和許多錯誤修復/增強功能。 盡管我們仍然嘗試跟蹤上游PIL的變化,(不幸或幸運的是,取決於您的查看方式)Pillow已開始偏離PIL。

對於Ubuntu,我發現我需要為python版本(2.7)安裝C頭文件包

sudo apt-get install python2.7-dev

之后, pip install pil工作了。

在Windows上,我在virtualenv中安裝了PIL,如下所示:

通過從以下網址執行.exe,將PIL安裝在全局python網站程序包中: http : //www.pythonware.com/products/pil/

然后,作為“自己動手做”,請將C:\\ Python25 \\ Lib \\ site-packages中的PIL.pth文件和PIL目錄復制到您的virtualenv site-packages目錄中。 是的,python仍然是一個“讓您的手變臟”的環境...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM