0

I try to run the example on http://ndres.me/post/matplotlib-animated-gifs-easily/:

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import imageio

def plot_for_offset(power, y_max):
    # Data for plotting
    t = np.arange(0.0, 100, 1)
    s = t**power

    fig, ax = plt.subplots(figsize=(10,5))
    ax.plot(t, s)
    ax.grid()
    ax.set(xlabel='X', ylabel='x^{}'.format(power),
           title='Powers of x')

    # IMPORTANT ANIMATION CODE HERE
    # Used to keep the limits constant
    ax.set_ylim(0, y_max)

    # Used to return the plot as an image rray
    fig.canvas.draw()       # draw the canvas, cache the renderer
    image = np.frombuffer(fig.canvas.tostring_rgb(), dtype='uint8')
    image  = image.reshape(fig.canvas.get_width_height()[::-1] + (3,))

    return image

kwargs_write = {'fps':1.0, 'quantizer':'nq'}
imageio.mimsave('./powers.gif', [plot_for_offset(i/4, 100) for i in range(10)], fps=1)

When I run this, Python tells me that there is a problem with Pillow:

RuntimeError: Imageio Pillow plugin requires Pillow lib.

Pillow is installed on my computer, as typing

>pip install pillow

returns

Requirement already satisfied: Pillow in c:\python27\lib\site-packages (2.8.2)

What does Imageio need?

Betohaku
  • 615
  • 1
  • 5
  • 8

1 Answers1

0

I think you have more than one python installed and your pip installs pillow to a different python location.

  • you can use this[https://stackoverflow.com/questions/647515/how-can-i-find-where-python-is-installed-on-windows] to find which python you are using. If its not "c:\python27\" then you might have to use ````pip install --target=PYTHONPATH\site-packages\ --upgrade pillow```` – Muhammed Ajwahir Feb 06 '19 at 11:28
  • I do indeed have two folders, and already copied all packages between them before posting the question. However, updating it by running `pip uninstall pillow` and `pip install pillow` and copying the PIL and pillow folders did solve the problem... I suppose the solution is just to update pillow. Genuine Q: considering the simple solution, should I delete the thread? – Betohaku Feb 06 '19 at 11:33
  • I guess not. Need not be simple for everyone. :) – Muhammed Ajwahir Feb 06 '19 at 11:38