python system_error ai_generated true

FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

ID: python/matplotlib-animation-ffmpeg-missing

Also available as: JSON · Markdown · 中文
80%Fix Rate
89%Confidence
0Evidence
2024-07-08First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active — — —

Root Cause

matplotlib.animation.FuncAnimation.save() defaults to ffmpeg writer, but ffmpeg is not on PATH.

generic

中文

matplotlib.animation.FuncAnimation.save() 默认使用 ffmpeg 写入器,但 ffmpeg 不在 PATH 中。

Workarounds

  1. 95% success
    sudo apt-get install -y ffmpeg
    # or: conda install -c conda-forge ffmpeg
  2. 90% success
    from matplotlib.animation import PillowWriter
    ani.save('anim.gif', writer=PillowWriter(fps=20))

Dead Ends

Common approaches that don't work:

  1. 92% fail

    The PyPI 'ffmpeg' package is a Python wrapper; it does not provide the ffmpeg binary.

  2. 90% fail

    The writer is already ffmpeg; the binary is what's missing.