使用virtualenv或buildout安装PIL的问题

发布于 2024-09-27 13:58:49 字数 756 浏览 1 评论 0原文

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

When I install PIL using easy_install or buildout it installs in such way, that I must do 'import Image', not 'from PIL import Image'.

However, if I do "apt-get install python-imaging" or use "pip -E test_pil install PIL", all work fine.

Here are examples of how I trying to install PIL using virtualenv:

# 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

I see, that easy_install pack PIL into the Egg, and PIP does not. Same thing with buildbot, it uses eggs.

How could I install PIL properly, using easy_install or buildout?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

小…红帽 2024-10-04 13:58:49

pypi 上打包的 PIL 版本(作者)与 setuptools 不兼容,因此无法 easy_installable。人们在其他地方创建了 easy_installable 版本。目前,您需要指定 find-links 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,请指定具有相同版本 pin 的 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 即可完成。 :-) 显然等待原始包被修复并没有得到回报。

The PIL version packaged on pypi (by the author) is incompatible with setuptools and thus not easy_installable. People have created easy_installable versions elsewhere. Currently, you need to specify a find-links URL and use pip get a good package:

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

By using pip install with the --no-index you avoid running the risk of finding the PyPI (non-fixed) original of PIL. If you were to use easy_install, you must use a direct link to the source tarball of a corrected version; easy_install stubbornly still uses the PyPI link over the find-links URL:

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

To include PIL in a buildout, either specify the egg with the same version pin or use a versions section:

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

[versions]
PIL = 1.1.7

Edit March 2011: Fixes to address the packaging issues have been merged into PIL's development tree now, so this workaround may soon be obsolete.

Edit February 2013: Just use Pillow and be done with it. :-) Clearly waiting for the original package to be fixed has not paid off.

哆啦不做梦 2024-10-04 13:58:49

使用 Pillow:“友好的”PIL 分支 :-) 它提供:

  • 完整的安装工具兼容性
  • 更快的发布周期
  • 没有图像代码更改与 PIL 不同(即,它的目标是跟踪所有 PIL 图像代码更改,并且在不向上游报告的情况下不进行任何自己的更改。)
  • Windows 二进制文件

如果 PIL 完全按照 Pillow 所做的事情,那么 fork 将消亡。在那之前,我们还有 Pillow。

免责声明:我是 fork 作者,创建 Pillow 主要是为了让我的工作更轻松(尽管很高兴看到其他人也使用它)。

编辑:Pillow 2.0.0 于 2013 年 3 月 15 日发布。它提供 Python 3 支持和许多错误修复/增强。虽然我们仍在尝试跟踪上游 PIL 的变化,(不幸或幸运取决于你如何看待它)Pillow 已经开始偏离 PIL。

Use Pillow: the "friendly" PIL fork :-) It offers:

  • Full setuptools compatibility
  • Faster release cycle
  • No image code changes that differ from PIL (i.e. it aims to track all PIL image code changes, and make none of its own changes without reporting them upstream.)
  • Windows binaries

If PIL ever does exactly what Pillow does, then the fork will die. Until that happens, we have Pillow.

DISCLAIMER: I am the fork author, and Pillow was created mainly to make my job easier (although it's great to see other folks using it too).

EDIT: Pillow 2.0.0 was released on March 15, 2013. It offers Python 3 support and many bug fixes/enhancements. While we still attempt to track changes with upstream PIL, (unfortunately or fortunately depending on how you look at it) Pillow has begun to drift away from PIL.

旧人哭 2024-10-04 13:58:49

对于 Ubuntu,我发现我需要为我的 python 版本 (2.7) 安装 C 头文件包

sudo apt-get install python2.7-dev

之后,pip install pil 工作了。

For Ubuntu I found I needed to to install the C headers package for my python version (2.7)

sudo apt-get install python2.7-dev

Afterwards, pip install pil worked.

无声情话 2024-10-04 13:58:49

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

通过执行以下位置的 .exe 在全局 python 站点包中安装 PIL:
http://www.pythonware.com/products/pil/

然后,作为“do it myself-er”,将 C:\Python25\Lib\site-packages 中的 PIL.pth 文件和 PIL 目录复制到 virtualenv site-packages 目录。是的,Python 仍然是一个“亲自动手”的环境......

On Windows, I installed PIL in a virtualenv as follows:

Install PIL in your global python site-packages by executing the .exe from:
http://www.pythonware.com/products/pil/

Then, as a "do it yourself-er", copy the PIL.pth file and PIL directory in C:\Python25\Lib\site-packages to your virtualenv site-packages directory. Yeah, python is still a "get your hands dirty" environment...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文