Moviepy: RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.

Created on 24 Apr 2020  路  10Comments  路  Source: Zulko/moviepy

Expected Behavior

not getting an error

Actual Behavior

getting the error in the title

Steps to Reproduce the Problem

be me and try to run from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip

ffmpeg is installed with apt and i can confirm its location in /usr/bin/. additionally ive also executed pip install imageio-ffmpeg in the python virtual environment and it is installed. ive logged platform.python_version() to confirm i was in the 3.8.0 venv.
executing a plain interpreter terminal in the venv and trying to import it manually does not resault in an error. only during execution. the execution is in a flask application deployed with gunicorn and nginx.

Specifications

  • Python Version: 3.8.0
  • Moviepy Version: the newest
  • Platform Name: Ubunto server
  • Platform Version: 18.04
bug environment ffmpeg

Most helpful comment

Ok, try this before importing moviepy:

import os
os.environ["IMAGEIO_FFMPEG_EXE"] = "/usr/bin/ffmpeg"

All 10 comments

i dont really know what an exe would be doing on linux anyway. but if theres some way to manually point it to /usr/bin/ffmpeg that might do it

I'm not sure why yours isn't working, but you can specifically point it to /usr/bin/ffmpeg by putting the following before importing anything else from moviepy:

from moviepy.config import change_settings
change_settings({"FFMPEG_BINARY": "/usr/bin/ffmpeg"})

or you can manually edit the file config_defaults.py.

Note that this will change in v2.0 (#1109). Either it will be fixed, or you'll have to use an environment variable.

If you'd like help fixing the actual problem of ffmpeg not being auto-detected, please provide the full traceback error that you get.

even that raises the same error.

  File "/home/project/project/server.py", line 14, in <module>
    from moviepy.config import change_settings
  File "/home/project/env/lib/python3.8/site-packages/moviepy/config.py", line 30, in <module>
    FFMPEG_BINARY = get_exe()
  File "/home/project/env/lib/python3.8/site-packages/imageio/plugins/ffmpeg.py", line 49, in get_exe
    return imageio_ffmpeg.get_ffmpeg_exe()
  File "/home/project/env/lib/python3.8/site-packages/imageio_ffmpeg/_utils.py", line 49, in get_ffmpeg_exe
    raise RuntimeError(
RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.

Ok, try this before importing moviepy:

import os
os.environ["IMAGEIO_FFMPEG_EXE"] = "/usr/bin/ffmpeg"

hmm that actually does seem to work. it imports without error. ill get back with a follow up if it actually works works and close the issue

Sure. It鈥檚 not a great solution, but maybe it will be properly fixed in v2.0.

Hi, I am also getting the same error while working in pydroid for Android (similar to linux environment)
But I am not able to solve this issue even after the import os. My error-

Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
    start(fakepyfile,mainpyfile)
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
    exec(open(mainpyfile).read(),  __main__.__dict__)
  File "<string>", line 4, in <module>
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/moviepy/video/io/VideoFileClip.py", line 88, in __init__
    self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 35, in __init__
    infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 257, in ffmpeg_parse_infos
    proc = sp.Popen(cmd, **popen_params)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/subprocess.py", line 856, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/subprocess.py", line 1728, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/ffmpeg'

Any help will be appreciated :)

Hi, I am also getting the same error while working in pydroid for Android (similar to linux environment)
But I am not able to solve this issue even after the import os. My error-

Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
    start(fakepyfile,mainpyfile)
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
    exec(open(mainpyfile).read(),  __main__.__dict__)
  File "<string>", line 4, in <module>
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/moviepy/video/io/VideoFileClip.py", line 88, in __init__
    self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 35, in __init__
    infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 257, in ffmpeg_parse_infos
    proc = sp.Popen(cmd, **popen_params)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/subprocess.py", line 856, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/subprocess.py", line 1728, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/ffmpeg'

Any help will be appreciated :)

sudo apt install ffmpeg
it will fix the issue

Ok, try this before importing moviepy:

import os
os.environ["IMAGEIO_FFMPEG_EXE"] = "/usr/bin/ffmpeg"

It works for me

The issue is that this appears on our HPC system sporadically, during model training.

So even if previous calls worked, this could happen during the same RunTime. There must be something pathological going on.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Deng-deng-deng-deng picture Deng-deng-deng-deng  路  3Comments

LaoYuanPython picture LaoYuanPython  路  3Comments

PyB1l picture PyB1l  路  3Comments

Netherdrake picture Netherdrake  路  4Comments

tburrows13 picture tburrows13  路  3Comments