SilentGrove_99
SilentGrove_99

Reputation: 731

Can't import moviepy due to missing ffmpex.exe

I was trying to create an application with python using the moviepy library. I installed it using:

pip install moviepy

I found this from a MoviePy crash-course:

# Import everything needed to edit video clips
from moviepy.editor import *
# or 
from moviepy import *  # moviepy v2 after removal of editor

After trying to run this line i get this error:

Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32     bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> # Import everything needed to edit video clips
... from moviepy.editor import *
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "C:\Python27\lib\site-packages\moviepy\editor.py", line 22, in <module>
    from .video.io.VideoFileClip import VideoFileClip
  File "C:\Python27\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 3, in <module>
    from moviepy.video.VideoClip import VideoClip
  File "C:\Python27\lib\site-packages\moviepy\video\VideoClip.py", line 20, in <module>
    from .io.ffmpeg_writer import ffmpeg_write_image, ffmpeg_write_video
  File "C:\Python27\lib\site-packages\moviepy\video\io\ffmpeg_writer.py", line 15, in <module>
    from moviepy.config import get_setting
  File "C:\Python27\lib\site-packages\moviepy\config.py", line 38, in <module>
    FFMPEG_BINARY = get_exe()
  File "C:\Python27\lib\site-packages\imageio\plugins\ffmpeg.py", line 86, in get_exe
    raise NeedDownloadError('Need ffmpeg exe. '
imageio.core.fetching.NeedDownloadError: Need ffmpeg exe. You can download it by calling:
  imageio.plugins.ffmpeg.download()

What is the problem here, and how can i fix it?

Upvotes: 21

Views: 83034

Answers (13)

Sanjeev Kumar
Sanjeev Kumar

Reputation: 11

The package has been modified and there is no editor package in moviepy 2.1.2

So use:

pip uninstall moviepy

pip install moviepy==2.0.0.dev2

Upvotes: 1

Ridola
Ridola

Reputation: 11

pip install imageio-ffmpeg

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

This solution will work out for you

Upvotes: 1

vindows.client
vindows.client

Reputation: 21

Yeah had same issue from moviepy.editor import VideoFileClip always ended up on module not found error.

Solution:

pip uninstall moviepy
pip install moviepy imageio decorator

Post installs, change the code to from moviepy.video.io.VideoFileClip import VideoFileClip

Upvotes: 0

beratcelik
beratcelik

Reputation: 63

After the November release of moviepy they removed the editor module and changed some directories.

to fix this error temporarily you can downgrade to Moviepy 1.0.3

pip uninstall moviepy
pip install moviepy==1.0.3

Upvotes: 0

Dibya Ranjan Rath
Dibya Ranjan Rath

Reputation: 51

Use the below command- (as there is some changes in moviepy)

from moviepy.video.io.VideoFileClip import VideoFileClip

Upvotes: 5

YULIANG WANG
YULIANG WANG

Reputation: 23

I use this code working fine:

from moviepy import VideoFileClip

Upvotes: 2

seems
seems

Reputation: 102

Maybe try to import asmoviepy import * according to the first example of the front page of the docs https://pypi.org/project/moviepy/ and download ffmpeg globally https://www.ffmpeg.org/

Upvotes: 0

Manveer Singh
Manveer Singh

Reputation: 131

solved by this command:

pip install moviepy==1.0.3 numpy>=1.18.1 imageio>=2.5.0 decorator>=4.3.0 tqdm>=4.0.0 Pillow>=7.0.0 scipy>=1.3.0 pydub>=0.23.0 audiofile>=0.0.0 opencv-python>=4.5

Upvotes: 13

If you're trying to do it on Jupyter (in VSCode) you should try %pip install moviepy, directly above the import command. Just like this:

%pip install moviepy
from moviepy.editor import *

Upvotes: 2

N&#39;Vida Yotcho
N&#39;Vida Yotcho

Reputation: 11

I encountered this issue today. When I installed MoviePy, every required component got installed as well ( I use pip ) but for some reason, I encountered that same issue. So, I literally tried everything that was mentioned above but still, nothing worked. The funny thing was that after investigated my /usr/bin/ I decided to switch from #!bin/python to #!/bin/python3 and I ended up getting error messages from pylint ( visual studio extension) - meaning it successfully imported moviepy.editor . But still, I was getting the same error so I decided to use python3 instead of python when executing my file.py and it worked. so my solution: python3 your_file_that_contains_moviepy.py I would also advise to alias pip3 as pip and python3 as python

Upvotes: 1

Ernest S Kirubakaran
Ernest S Kirubakaran

Reputation: 1564

I had a similar issue. It got fixed by the following line of code.

python -m pip install moviepy

Upvotes: 5

fr_andres
fr_andres

Reputation: 6677

I was having a similar issue; the ffmpeg plugin was downloaded automatically for me, but still couldn't import the editor. In my case, another dependency was missing: I fixed it by doing a

pip install --user requests


EXPLANATION:

  • (Context: not needed but maybe helpful for others) I needed the imagepy.editor in order to send some tensors as video to TensorBoard using the amazing tensorboardX project. Since I still had an import error, tbX kept telling me that I need imagepy, which I had. See the corresponding GitHub issue that I opened for more details.

  • Taking a closer look at the module via import imagepy; help(imagepy), I saw the editor submodule listed, which further confused me: trying to import it returned AttributeError: 'module' object has no attribute 'editor'

  • So the actual error had to be covered somewhere. I commented out the only line in the module's __init__ fle (which you can find via imagepy.__file__) and added an explicit import editor, which unleashed the error message: ImportError: No module named requests

At this point, installing the requests package and restoring the __init__file to its original state did the job. Hope this helps!

Cheers, Andres

Upvotes: 1

Tom Burrows
Tom Burrows

Reputation: 2365

EDIT: You can now update moviepy to v0.2.3.3 with pip install --upgrade moviepy and it will automatically install ffmpeg when required upon import of moviepy.editor (#731)


Run in a python console/shell (e.g. IPython/IDLE shell):

>>> import imageio
>>> imageio.plugins.ffmpeg.download()

Moviepy depends on the library imageio, which uses the program ffmpeg. It needs to download it before it can use it, and you can download it with the above imageio command.

Upvotes: 19

Related Questions