ubuntu14.04环境下python3 Image.show()不显示图片问题

  我使用了python3.4,Pillow2.9。但在使用下面代码时,show()没有动作。

from PIL import Image

image = Image.open('captcha.gif')
image.show()

查了好久,才在是stackoverflow上找到解决方法。分两种:

1 安装imagemagick: sudo apt-get install imagemagick。

2 修改Pillow文件:在ImageShow.py(位置在usr/local/lib/python3.4/dist-packages的Pillow-2.9.0~.egg中)代码片段中把"display"替换为"eog"。其中display时imagemagick的命令行启动命令,eog则是系统默认图片查看器的。

   class DisplayViewer(UnixViewer):
        def get_command_ex(self, file, **options):
            command = executable = "display"
            return command, executable

    if which("display"):
        register(DisplayViewer)


两者相比,第一个方法很方便、简单。第二个方法没有成功,因为我无法修改ImageShow.py文件。


参考stackoverflow的热情解答:http://stackoverflow.com/questions/16279441/image-show-wont-display-the-picture





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值