您的位置:首页 > 编程语言 > Python开发

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

2015-09-18 19:56 561 查看
  我使用了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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python Image.show ubuntu