Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error message if no animation writer is available #5616

Closed
jankatins opened this issue Dec 4, 2015 · 4 comments · Fixed by #5628
Closed

Better error message if no animation writer is available #5616

jankatins opened this issue Dec 4, 2015 · 4 comments · Fixed by #5628
Milestone

Comments

@jankatins
Copy link
Contributor

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

@jankatins jankatins changed the title Better error message if no AnnimationWriter is available Better error message if no animation writer is available Dec 4, 2015
@tacaswell tacaswell added this to the proposed next point release (2.1) milestone Dec 4, 2015
@tacaswell
Copy link
Member

The registration code should be user re-triggerable as well.

@jankatins
Copy link
Contributor Author

Is there a way to register a retrigger by setting a rcParam value?

@jankatins
Copy link
Contributor Author

ok, found a way to do that via the validation code... Will submit a PR...

@jankatins
Copy link
Contributor Author

Ok, my solution has a problem: The validation happens before the value is assigned, so calling the animation code there isn't going to trigger a new result. I see a few ways to solve this:

  • make validation function return a tupple (new_validated_val, func_after_setting), which the rcParam objects calls after setting the value
  • add a func_after_setting to the list of rcparam setup values, so if that's not None, call it after setting
  • add a dirty state to the writer registry and make it re-setup when it's dirty.

If you don't have any other idea, I would go with the last idea as this seems to be the least invasive one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants