본문 바로가기
2/[ Python ]

[Error] TypeError: __init__() got an unexpected keyword argument 'extra_args'

by Kieran_Han 2023. 5. 16.

Error entire text

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[14], line 25
     21 anim = animation.FuncAnimation(fig, animate, init_func=init,
     22                                frames=FRAMES, interval=100)
     24 # call our new function to display the animation
---> 25 display_animation(anim)

Cell In[13], line 3, in display_animation(anim)
      1 def display_animation(anim):
      2     plt.close(anim._fig)
----> 3     return HTML(anim_to_html(anim))

Cell In[10], line 9, in anim_to_html(anim)
      7 if not hasattr(anim, '_encoded_video'):
      8     f = NamedTemporaryFile(suffix='.mp4', delete=False)
----> 9     anim.save(f.name, fps=20, extra_args=['-vcodec', 'libx264', '-pix_fmt', 'yuv420p'])
     10     f.flush()
     11     video = open(f.name, "rb").read()

File C:\ProgramData\anaconda3\envs\ML\lib\site-packages\matplotlib\animation.py:1051, in Animation.save(self, filename, writer, fps, dpi, codec, bitrate, extra_args, metadata, extra_anim, savefig_kwargs, progress_callback)
   1048         writer_cls = PillowWriter  # Always available.
   1049         _log.warning("MovieWriter %s unavailable; using Pillow "
   1050                      "instead.", writer)
-> 1051     writer = writer_cls(fps, **writer_kwargs)
   1052 _log.info('Animation.save using %s', type(writer))
   1054 if 'bbox_inches' in savefig_kwargs:

TypeError: __init__() got an unexpected keyword argument 'extra_args'

 

To solve above problem, Installing ffmpeg by

conda install -c conda-forge av

on CMD