Can't import moviepy.editor

Question:

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 *

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:Python27libsite-packagesmoviepyeditor.py", line 22, in <module>
    from .video.io.VideoFileClip import VideoFileClip
  File "C:Python27libsite-packagesmoviepyvideoioVideoFileClip.py", line 3, in <module>
    from moviepy.video.VideoClip import VideoClip
  File "C:Python27libsite-packagesmoviepyvideoVideoClip.py", line 20, in <module>
    from .io.ffmpeg_writer import ffmpeg_write_image, ffmpeg_write_video
  File "C:Python27libsite-packagesmoviepyvideoioffmpeg_writer.py", line 15, in <module>
    from moviepy.config import get_setting
  File "C:Python27libsite-packagesmoviepyconfig.py", line 38, in <module>
    FFMPEG_BINARY = get_exe()
  File "C:Python27libsite-packagesimageiopluginsffmpeg.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?

Asked By: Ingmar05

||

Answers:

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.

Answered By: Tom Burrows

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

Answered By: fr_andres

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

python -m pip install moviepy

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

Answered By: N'Vida Yotcho

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 *
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.