Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Better error message if no animation writer is available #5616

Closed
@jankatins

Description

@jankatins

You have to set one before importing animation:

# Must be set before the animation import
mpl.rcParams['animation.ffmpeg_path'] = "C:\\Users\\jschulz\\Dropbox\\Programme\\cmder\\vendor\\jasc\\ffmpeg.exe"
import matplotlib.animation as animation

Without:

C:\portabel\miniconda\envs\katins2\lib\site-packages\matplotlib\animation.py:781: UserWarning: MovieWriter ffmpeg unavailable
  warnings.warn("MovieWriter %s unavailable" % writer)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-2c23ec3f11d2> in <module>()
     25 
     26 ani = animation.FuncAnimation(plt.gcf(), updatefig, frames=40, init_func=initfig)
---> 27 ani.save('_movie.mp4')

C:\portabel\miniconda\envs\katins2\lib\site-packages\matplotlib\animation.pyc in save(self, filename, writer, fps, dpi, codec, bitrate, extra_args, metadata, extra_anim, savefig_kwargs)
    786                                                         metadata=metadata)
    787                 except IndexError:
--> 788                     raise ValueError("Cannot save animation: no writers are "
    789                                      "available. Please install mencoder or "
    790                                      "ffmpeg to save animations.")

ValueError: Cannot save animation: no writers are available. Please install mencoder or ffmpeg to save animations.

This runtime error should give that information: https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/animation.py#L788

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions