我在python3.5.2上使用images2gif时遇到错误。
我已经遇到了一些我找到答案的问题,但是没有在任何地方看到这个问题。
代码:
from PIL import Image
from images2gif import writeGif
import urllib.request
image_files=["list of png image files in the same directory as the script"]
images = [Image.open(fn) for fn in image_files]
gif_file = "test-gif.GIF"
writeGif(gif_file, images, duration=44)
错误:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-19-75192c4aeed1> in <module>()
7
8 gif_file = "test-gif.GIF"
----> 9 writeGif(gif_file, images, duration=44)
C:\Users\mchoy2\AppData\Local\Continuum\Anaconda3\lib\site-packages\images2gif\images2gif.py in writeGif(filename, images, duration, repeat, dither, nq, subRectangles, dispose)
591 fp = open(filename, 'wb')
592 try:
--> 593 gifWriter.writeGifToFile(fp, images, duration, loops, xy, dispose)
594 finally:
595 fp.close()
C:\Users\mchoy2\AppData\Local\Continuum\Anaconda3\lib\site-packages\images2gif\images2gif.py in writeGifToFile(self, fp, images, durations, loops, xys, disposes)
446
447 # Write
--> 448 fp.write(header)
449 fp.write(globalPalette)
450 fp.write(appext)
TypeError: a bytes-like object is required, not 'str'
编辑:已更新,并显示完整的错误消息
答案 0 :(得分:0)
显示错误消息,因为images2gif是针对python 2.x而非3.x
生成的