使用images2gif.py创建GIF时出错 [英] Error when creating GIF using images2gif.py

查看:995
本文介绍了使用images2gif.py创建GIF时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 visvis 软件包中的images2fig.py创建GIF文件

I'm trying to create a GIF file using images2fig.py from the visvis package

使用这个非常简单的代码:

With this very simple code:

import glob
from PIL import Image
from visvis.vvmovie.images2gif import writeGif

images = [Image.open(image) for image in glob.glob("*.png")]
filename = "test.gif"
writeGif(filename, images, duration=0.2)

我收到了错误

  File "C:\Python27\lib\site-packages\visvis\vvmovie\images2gif.py", line 575, in writeGif
    gifWriter.writeGifToFile(fp, images, duration, loops, xy, dispose)

  File "C:\Python27\lib\site-packages\visvis\vvmovie\images2gif.py", line 436, in writeGifToFile
    fp.write(globalPalette)

TypeError: must be string or buffer, not list

我如何修复这个?

我使用的是Python 2.7.5,Pillow 2.1.0,numpy 1.7.1-2,都是Python(x,y)2.7的标准安装Windows上为.5,最新版本为visvis 1.8。我试图重新安装包,但它没有帮助。我仍然得到同样的错误。我的一个朋友也在他的电脑上复制了这个错误。

I'm using Python 2.7.5, Pillow 2.1.0, numpy 1.7.1-2, all are standard installation from Python(x,y) 2.7.5 on Windows, and visvis 1.8 which is the latest version. I tried to reinstall the packages but it did not help. I still get the same error. A friend of mine reproduced the error on his computer too.

推荐答案

@korylprince我通过以下两项修改解决了问题:

@korylprince I fixed the problem with the following two changes:


  1. 我卸载了Python(x,y),安装了Anaconda(32位),然后通过pip安装了
    visvis。

  1. I uninstalled Python(x,y), installed Anaconda (32-bit), then installed visvis via pip.

现在我使用 imread(image)代替PIL Image,加载图片
成numpy数组。

Instead of PIL Image, now I use imread(image), which load image into a numpy array.

在另一台计算机上我没有卸载Python(x,y),而是我卸载了 Pillow 2.1.0 并安装了 PIL 1.1.7 ,并且还替换了与上面步骤2相同的代码。以这种方式,它使用Python(x,y)。所以问题是 Pillow 2.1.0

On another computer I did not uninstall Python(x,y), instead I uninstalled Pillow 2.1.0 and installed PIL 1.1.7, and also replaced the code same as step 2 above. In that way it worked with Python(x,y). So the problem is Pillow 2.1.0.

这篇关于使用images2gif.py创建GIF时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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