The problem#

Requested MovieWriter (ffmpeg) not available

Solution#

Requirements#

  • conda env with ffmpeg and ipykernel

  • conda env available in jupyter notebook (see Use your own kernel)

Optionally, PATH of ffmpeg software binaries on Levante.

What do you need to change/add#

if you installed ffmpeg-python in your conda env:

conda install -c conda-forge ffmpeg

you only need to modify the kernel.json to add the PATH of the ffmpeg like this:

{
 "argv": [
  "/path/to/your/conda/env/bin/python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "my kernel",
 "language": "python",
 "env": {
    "PATH":
       "/path/to/your/conda_env/bin:$PATH"
       }
}

Note

This only concerns missing ffmpeg, some additional packages might be required depending on your code!

Example#

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


fig, ax = plt.subplots(1,1)
x=np.linspace(np.pi,4*np.pi,100)
N=len(x)
ax.set_xlim(len(x))
ax.set_ylim(-1.5,1.5)
line,  = ax.plot([],[],'o-')

def init():
    line.set_ydata(np.ma.array(x[:], mask=True))
   return line,

def animate(i, *args, **kwargs):
    y=np.sin(x*i)
    line.set_data(np.arange(N),y)            # update the data
    return line,

ani = animation.FuncAnimation(fig, animate, init_func=init,
     frames=100, interval=10, blit= False, repeat = False)

ani.save('test.mp4', writer="ffmpeg")
fig.show()

Troubleshootings#

  • libmkl_intel_thread.so.1: undefined symbol: omp_get_num_procs can be solved by:

    conda install –channel conda-forge llvm-openmp

  • ImportError: failed to import graphviz; ... solved by:

    conda install –channel conda-forge python-graphviz