0

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)

I got an error

  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

How do I fix this?

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.

7
  • Using pip to install visvis and PIL, I ran your exact code on two png files and had no errors on linux. Is that the actual code you ran? Commented Aug 20, 2013 at 2:28
  • @korylprince Yes that's the code I'm running. I'm on Windows though. I updated PIL from 2.0.0 to 2.1.0 but Python(x,y) is still showing 2.0.0, maybe that is the problem. But I don't know how to properly update the package, the "remove package" function doesn't work.
    – LWZ
    Commented Aug 20, 2013 at 2:45
  • perhaps you should try running help(writeGif) to learn about the particular version of the function you are running. Commented Aug 20, 2013 at 2:48
  • @korylprince it says PILLOW_VERSION = '2.1.0' VERSION = '1.1.7' , seems like it's updated properly. How can I reinstall the packages using pip on Windows? Worth a try.
    – LWZ
    Commented Aug 20, 2013 at 2:51
  • I'm not sure... You can just install pip on windows then run pip install PIL visvis. That might get it working. Commented Aug 20, 2013 at 2:54

1 Answer 1

1

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

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

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.