如何在Ubuntu 11.04中安装PIL? [英] How to install PIL in Ubuntu 11.04?

查看:111
本文介绍了如何在Ubuntu 11.04中安装PIL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到整个互联网都在问这个问题,我已经尝试了全部跟踪,但仍然无法使PIL正常工作.

I see this question asked all over the internet, and I've tried following them all, but I still can't get PIL to work.

我尝试通过以下方式象征性地链接zlib,jpeg等库:

I tried symbolically linking the zlib, jpeg, etc. libraries via:

sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib/
sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/

我尝试编辑setup.py文件,并添加以下行:

I tried editing the setup.py file, adding this line:

add_directory(library_dirs, "/usr/lib/x86_64-linux-gnu")

实际上,运行$ sudo python setup.py install表示JPEG,ZLIB/PNG等支持可用. (我同时安装了2.5和2.7版,两者都无法使用)

In fact, running $ sudo python setup.py install shows that JPEG, ZLIB/PNG, etc. support is Available. (I'm installing it for both 2.5 and 2.7, works in neither)

sudo python2.5 setup.py install
running install
running build
running build_py
running build_ext
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version       1.1.7
platform      linux2 2.5.6 (r256:88840, Feb  1 2012, 15:55:08)
              [GCC 4.5.2]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
--- LITTLECMS support available

但是毕竟,我 still 仍然出现decoder %s not available错误.

But after all that, I still get a decoder %s not available error.

我机智.还有什么我可能想念的吗?

I'm at my wits end. Anything else I might have missed?

我的环境: 在VirtualBox VM中运行的 64位Ubuntu 11.04 .

My environment: 64-bit Ubuntu 11.04 running in a VirtualBox VM.

这是我测试PIL是否有效的方法

Here's what I do to test if PIL works or not

$ python
>>> from PIL import Image
>>> im = Image.open("photo.jpg")
>>> im.rotate(45)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1359, in rotate
  self.load()
File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 189, in load
  d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 385, in _getdecoder
  raise IOError("decoder %s not available" % decoder_name)
IOError: decoder zip not available
>>> 

推荐答案

与往常一样,使用程序包管理器:

As always, use the package manager:

sudo apt-get install python-imaging

它将为您处理所有这一切. 软件包可用.

It'll deal with it all for you. The packages are available.

在任何Linux发行版中,手动安装都是浪费时间,除非软件包确实不存在.软件包维护者会花费时间来确保软件包能够正常工作和安装,没有必要重复他们的工作.特别是不要手动安装那些没有软件包优势的东西-无法自动更新,无法轻松删除等...

Manually installing, in any Linux distro, is a wasted endeavour, unless the packages really don't exist. Package maintainers spend time ensuring that the package works and installs correctly, there is no point duplicating their effort. Especially not to manually install something that then doesn't have the advantages of a package - no automatic updating, no easy removal, etc...

这篇关于如何在Ubuntu 11.04中安装PIL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆