'Python Notebook Create and Display GIF Without Saving to File

In Jupyter Notebook, you can have an image from a Numpy array and show it without having to save it, like so:

from PIL import Image
import numpy as np

array = np.zeroes((100,100))
img = Image.fromarray(array)
img.show()

Is it possible to do the same with a GIF, without having to write to a file? Assuming I already have a list of images I want to show as a GIF within the notebook. Something like this:

list_of_images # assume it's loaded beforehand
gif_img = to_gif(list_of_images)
gif_img.show()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source