AttributeError: 'VideoFileClip' object has no attribute 'subclip' (or 'set_duration', 'resize', 'fx', 'volumex'), No module named 'moviepy.editor': every name MoviePy 2 changed and what to write instead
MoviePy 2.0.0 (2024-11-20) removed moviepy.editor and renamed the clip methods. Write from moviepy import VideoFileClip; subclip is subclipped, the set_x methods are with_x (with_duration, with_position, with_audio), resize / crop / rotate are resized / cropped / rotated, volumex is with_volume_scaled, and clip.fx(vfx.fadein, 1) is clip.with_effects([vfx.FadeIn(1)]). Or keep the old names with pip install "moviepy<2". Many tutorials still show 1.x code: paste the error or the code below.
# MoviePy 1.x
from moviepy.editor import *
clip = VideoFileClip("in.mp4").subclip(5, 10)
clip = clip.resize(0.5).set_fps(24)
clip = clip.fx(vfx.fadein, 1).volumex(0.8)
txt = TextClip("Hi", fontsize=40, color="white")
txt = txt.set_position("center").set_duration(5)
CompositeVideoClip([clip, txt]).write_videofile("out.mp4")
# MoviePy 2.x
from moviepy import *
clip = VideoFileClip("in.mp4").subclipped(5, 10)
clip = clip.resized(0.5).with_fps(24)
clip = clip.with_effects([vfx.FadeIn(1)]).with_volume_scaled(0.8)
txt = TextClip(text="Hi", font="DejaVuSans.ttf", font_size=40, color="white")
txt = txt.with_position("center").with_duration(5)
CompositeVideoClip([clip, txt]).write_videofile("out.mp4")
Examples:
Runs in your browser on the data in this page (moviepy_names.json); nothing you paste is sent anywhere.
Which clip methods did MoviePy 2 rename?
53 clip members are in 1.0.3 and not in 2.2.1; 51 of them went in 2.0.0 (blit_on in 2.1.2) (make_frame in 2.1.0). "Same result" means the 1.x call in 1.0.3 and the 2.x call in 2.2.1 were run on the same test clip and gave identical duration, size, frame, mask and audio numbers.
| MoviePy 1.x | MoviePy 2.x |
|---|---|
clip.subclipevery clip | clip.subclipped(start, end) (same result in 1.0.3 and 2.2.1) |
clip.set_durationevery clip | clip.with_duration(t) (same result in 1.0.3 and 2.2.1) |
clip.set_startevery clip | clip.with_start(t) (same result in 1.0.3 and 2.2.1) |
clip.set_endevery clip | clip.with_end(t) (same result in 1.0.3 and 2.2.1) |
clip.set_positionvideo clips | clip.with_position(pos) (same result in 1.0.3 and 2.2.1) |
clip.set_posvideo clips | clip.with_position(pos) (same result in 1.0.3 and 2.2.1) |
clip.set_audiovideo clips | clip.with_audio(audioclip) (same result in 1.0.3 and 2.2.1) |
clip.set_fpsevery clip | clip.with_fps(fps) (same result in 1.0.3 and 2.2.1) |
clip.set_opacityvideo clips | clip.with_opacity(x) (same result in 1.0.3 and 2.2.1) |
clip.set_maskvideo clips | clip.with_mask(maskclip) (same result in 1.0.3 and 2.2.1) |
clip.resizevideo clips | clip.resized(0.5), clip.resized(width=320) or clip.resized((w, h)); as an effect: vfx.Resize(...) (same result in 1.0.3 and 2.2.1) |
clip.cropvideo clips | clip.cropped(x1=, y1=, x2=, y2=); as an effect: vfx.Crop(...) (same result in 1.0.3 and 2.2.1) |
clip.rotatevideo clips | clip.rotated(angle, expand=True), or clip.with_effects([vfx.Rotate(angle)]). Plain clip.rotated(90) kept the 64x48 frame where 1.x gave 48x64. (same result in 1.0.3 and 2.2.1) |
clip.fxevery clip | clip.with_effects([vfx.MirrorX()]): effects are classes now, passed in a list (1.x: clip.fx(vfx.mirror_x)) (same result in 1.0.3 and 2.2.1) |
clip.fl_imagevideo clips | clip.image_transform(lambda frame: ...) (same result in 1.0.3 and 2.2.1) |
clip.flevery clip | clip.transform(lambda get_frame, t: ...) (same result in 1.0.3 and 2.2.1) |
clip.fl_timeevery clip | clip.time_transform(lambda t: ...) (same result in 1.0.3 and 2.2.1) |
clip.fadeinvideo clips | clip.with_effects([vfx.FadeIn(duration)]) (same result in 1.0.3 and 2.2.1) |
clip.fadeoutvideo clips | clip.with_effects([vfx.FadeOut(duration)]) (same result in 1.0.3 and 2.2.1) |
clip.crossfadeinvideo clips | clip.with_effects([vfx.CrossFadeIn(duration)]) (same result in 1.0.3 and 2.2.1) |
clip.crossfadeoutvideo clips | clip.with_effects([vfx.CrossFadeOut(duration)]) (same result in 1.0.3 and 2.2.1) |
clip.speedxvideo clips | clip.with_speed_scaled(factor), or clip.with_effects([vfx.MultiplySpeed(factor)]) (same result in 1.0.3 and 2.2.1) |
clip.volumexevery clip | clip.with_volume_scaled(factor), or clip.with_effects([afx.MultiplyVolume(factor)]) (same result in 1.0.3 and 2.2.1) |
clip.loopvideo clips | clip.with_effects([vfx.Loop(n=2)]) or vfx.Loop(duration=...) (same result in 1.0.3 and 2.2.1) |
clip.marginvideo clips | clip.with_effects([vfx.Margin(size)]) (same result in 1.0.3 and 2.2.1) |
clip.on_colorvideo clips | clip.with_background_color(size=, color=, pos=, opacity=): the argument col_opacity is now opacity (same result in 1.0.3 and 2.2.1) |
clip.invert_colorsvideo clips | clip.with_effects([vfx.InvertColors()]) (same result in 1.0.3 and 2.2.1) |
clip.audio_fadeinevery clip | clip.with_effects([afx.AudioFadeIn(duration)]) (same result in 1.0.3 and 2.2.1) |
clip.audio_fadeoutevery clip | clip.with_effects([afx.AudioFadeOut(duration)]) (same result in 1.0.3 and 2.2.1) |
clip.audio_normalizeevery clip | clip.with_effects([afx.AudioNormalize()]) (same result in 1.0.3 and 2.2.1) |
clip.audio_loopaudio clips | clip.with_effects([afx.AudioLoop(n_loops=2)]) (ran in 2.2.1 (the 1.0.3 call raised here)) |
clip.afxvideo clips | clip.with_effects([afx.MultiplyVolume(0.5)]): audio effects go in the same list (same result in 1.0.3 and 2.2.1) |
clip.subfxvideo clips | clip.with_effects_on_subclip([vfx.MirrorX()], start, end) (same result in 1.0.3 and 2.2.1) |
clip.cutoutevery clip | clip.with_section_cut_out(start, end) (same result in 1.0.3 and 2.2.1) |
clip.add_maskvideo clips | clip.with_mask() with no argument (same result in 1.0.3 and 2.2.1) |
clip.set_ismaskevery clip | clip.with_is_mask(True) (same result in 1.0.3 and 2.2.1) |
clip.set_make_frameevery clip | clip.with_updated_frame_function(f) (same result in 1.0.3 and 2.2.1) |
clip.set_memoizeevery clip | clip.with_memoize(True) (same result in 1.0.3 and 2.2.1) |
clip.ismaskvideo clips | clip.is_mask (same result in 1.0.3 and 2.2.1) |
clip.make_frameVideoClip, VideoFileClip, ImageClip, ColorClip, CompositeVideoClip, AudioClip, AudioFileClip | clip.frame_function (same result in 1.0.3 and 2.2.1) |
clip.ipython_displayevery clip | clip.display_in_notebook() (the 2.x name is there; not run) |
clip.to_videofilevideo clips | clip.write_videofile(...), the name 1.0.3 already has |
clip.to_gifvideo clips | clip.write_gif(...), the name 1.0.3 already has |
clip.to_images_sequencevideo clips | clip.write_images_sequence(...), the name 1.0.3 already has |
clip.to_audiofileaudio clips | clip.write_audiofile(...), the name 1.0.3 already has |
clip.blit_onvideo clips | no 2.x name found |
clip.coreaderAudioFileClip | no 2.x name found |
clip.listTextClip | gone: 2.x draws text with Pillow, not ImageMagick; pass font="/path/to/font.ttf" |
clip.mask_andvideo clips | clip.with_effects([vfx.MasksAnd(other)]) (the class is there; not run) |
clip.mask_orvideo clips | clip.with_effects([vfx.MasksOr(other)]) (the class is there; not run) |
clip.memoize_frameVideoClip, VideoFileClip, ImageClip, ColorClip, CompositeVideoClip, AudioClip, AudioFileClip | clip.memoized_frame (the 2.x name is there; not run) |
clip.previewaudio clips | clip.audiopreview() (the 2.x name is there; not run) |
clip.searchTextClip | gone: 2.x draws text with Pillow, not ImageMagick; pass font="/path/to/font.ttf" |
What replaces from moviepy.editor import ...?
moviepy.editor is gone in every 2.x release; its names are at the top of the package. What from moviepy.editor import * gave in 1.0.3, and where each is in 2.2.1:
| In moviepy.editor (1.0.3) | MoviePy 2.x |
|---|---|
AudioClip | from moviepy import AudioClip |
AudioFileClip | from moviepy import AudioFileClip |
ColorClip | from moviepy import ColorClip |
CompositeAudioClip | from moviepy import CompositeAudioClip |
CompositeVideoClip | from moviepy import CompositeVideoClip |
ImageClip | from moviepy import ImageClip |
ImageSequenceClip | from moviepy import ImageSequenceClip |
TextClip | from moviepy import TextClip |
VideoClip | from moviepy import VideoClip |
VideoFileClip | from moviepy import VideoFileClip |
afx | from moviepy import afx |
clips_array | from moviepy import clips_array |
concatenate | from moviepy import concatenate_videoclips (same result in 1.0.3 and 2.2.1) |
concatenate_audioclips | from moviepy import concatenate_audioclips |
concatenate_videoclips | from moviepy import concatenate_videoclips |
cvsecs | from moviepy import convert_to_seconds (same result in 1.0.3 and 2.2.1) |
download_webfile | not in 2.x |
ffmpeg_tools | from moviepy import ffmpeg_tools |
ipython_display | from moviepy import display_in_notebook, or clip.display_in_notebook() |
preview | clip.preview() (a method of the clip) |
show | clip.show() (a method of the clip) |
transfx | from moviepy import vfx: transfx.crossfadein is vfx.CrossFadeIn, transfx.slide_in is vfx.SlideIn (also CrossFadeOut, SlideOut) (same result in 1.0.3 and 2.2.1) |
vfx | from moviepy import vfx |
videotools | from moviepy import videotools |
Modules that 1.0.3 has and 2.2.1 does not (54; the 36 one-function effect modules such as moviepy.video.fx.resize are in the next table):
| Module (1.x) | MoviePy 2.x |
|---|---|
moviepy.audio.fx.all | from moviepy import afx: the effects are classes in moviepy.audio.fx (afx.MultiplyVolume, afx.AudioFadeIn, ...) |
moviepy.audio.io.preview | gone; no 2.x module of that name |
moviepy.compat | gone; no 2.x module of that name |
moviepy.config_defaults | gone; no 2.x module of that name |
moviepy.editor | from moviepy import VideoFileClip (every class is at the top now; from moviepy import * also works). 1.x: from moviepy.editor import * |
moviepy.utils | close_all_clips is in moviepy.tools |
moviepy.video.compositing.concatenate | from moviepy import concatenate_videoclips (it now lives in moviepy.video.compositing.CompositeVideoClip) |
moviepy.video.compositing.on_color | gone; no 2.x module of that name |
moviepy.video.compositing.positioning | gone; no 2.x module of that name |
moviepy.video.compositing.transitions | from moviepy import vfx: vfx.CrossFadeIn, vfx.CrossFadeOut, vfx.SlideIn, vfx.SlideOut |
moviepy.video.fx.all | from moviepy import vfx: the effects are classes in moviepy.video.fx (vfx.Resize, vfx.FadeIn, ...) |
moviepy.video.io.bindings | gone; no 2.x module of that name |
moviepy.video.io.downloader | gone; no 2.x module of that name |
moviepy.video.io.html_tools | moviepy.video.io.display_in_notebook |
moviepy.video.io.preview | moviepy.video.io.ffplay_previewer |
moviepy.video.io.sliders | gone; no 2.x module of that name |
moviepy.video.tools.segmenting | gone; no 2.x module of that name |
moviepy.video.tools.tracking | gone; no 2.x module of that name |
Which effect class replaces each vfx / afx function?
Effects are classes in 2.x, applied with clip.with_effects([...]). The module moved with the name: moviepy.video.fx.resize is moviepy.video.fx.Resize.
| 1.x function | 2.x class |
|---|---|
vfx.accel_decel | vfx.AccelDecel (the 2.x name is there; not run) |
vfx.blackwhite | vfx.BlackAndWhite (same result in 1.0.3 and 2.2.1) |
vfx.blink | vfx.Blink (ran in 2.2.1 (the 1.0.3 call raised here)) |
vfx.colorx | vfx.MultiplyColor (same result in 1.0.3 and 2.2.1) |
vfx.crop | vfx.Crop (same result in 1.0.3 and 2.2.1) |
vfx.even_size | vfx.EvenSize (same result in 1.0.3 and 2.2.1) |
vfx.fadein | vfx.FadeIn (same result in 1.0.3 and 2.2.1) |
vfx.fadeout | vfx.FadeOut (same result in 1.0.3 and 2.2.1) |
vfx.freeze | vfx.Freeze (same result in 1.0.3 and 2.2.1) |
vfx.freeze_region | vfx.FreezeRegion (the 2.x name is there; not run) |
vfx.gamma_corr | vfx.GammaCorrection (same result in 1.0.3 and 2.2.1) |
vfx.headblur | vfx.HeadBlur (the 2.x name is there; not run) |
vfx.invert_colors | vfx.InvertColors (same result in 1.0.3 and 2.2.1) |
vfx.loop | vfx.Loop (same result in 1.0.3 and 2.2.1) |
vfx.lum_contrast | vfx.LumContrast (same result in 1.0.3 and 2.2.1) |
vfx.make_loopable | vfx.MakeLoopable (same result in 1.0.3 and 2.2.1) |
vfx.margin | vfx.Margin (same result in 1.0.3 and 2.2.1) |
vfx.mask_and | vfx.MasksAnd (the 2.x name is there; not run) |
vfx.mask_color | vfx.MaskColor (same result in 1.0.3 and 2.2.1) |
vfx.mask_or | vfx.MasksOr (the 2.x name is there; not run) |
vfx.mirror_x | vfx.MirrorX (same result in 1.0.3 and 2.2.1) |
vfx.mirror_y | vfx.MirrorY (same result in 1.0.3 and 2.2.1) |
vfx.painting | vfx.Painting (the 2.x name is there; not run) |
vfx.resize | vfx.Resize (same result in 1.0.3 and 2.2.1) |
vfx.rotate | vfx.Rotate (same result in 1.0.3 and 2.2.1) |
vfx.scroll | vfx.Scroll (the 2.x name is there; not run) |
vfx.speedx | vfx.MultiplySpeed (same result in 1.0.3 and 2.2.1) |
vfx.supersample | vfx.SuperSample (the 2.x name is there; not run) |
vfx.time_mirror | vfx.TimeMirror (ran in both; the result was not identical) |
vfx.time_symmetrize | vfx.TimeSymmetrize (same result in 1.0.3 and 2.2.1) |
afx.audio_fadein | afx.AudioFadeIn (same result in 1.0.3 and 2.2.1) |
afx.audio_fadeout | afx.AudioFadeOut (same result in 1.0.3 and 2.2.1) |
afx.audio_left_right | afx.MultiplyStereoVolume (ran in 2.2.1 (the 1.0.3 call raised here)) |
afx.audio_loop | afx.AudioLoop (ran in 2.2.1 (the 1.0.3 call raised here)) |
afx.audio_normalize | afx.AudioNormalize (same result in 1.0.3 and 2.2.1) |
afx.volumex | afx.MultiplyVolume (same result in 1.0.3 and 2.2.1) |
Which arguments did MoviePy 2 rename or drop?
Read from the signatures of 1.0.3 and 2.2.1. In 2.2.1, TextClip(fontsize=20) raises "TypeError: got an unexpected keyword argument 'fontsize'" and write_videofile(verbose=False) raises "TypeError: got an unexpected keyword argument 'verbose'".
| Call | 1.x argument → 2.x |
|---|---|
TextClip() | txt → text=; fontsize → font_size=; kerning gone; align gone (2.x has text_align=, horizontal_align=, vertical_align=); tempfilename gone; temptxt gone; remove_temp gone; print_cmd gone |
ColorClip() | ismask → is_mask=; col → color= |
VideoClip() | make_frame → frame_function= (from 2.1.0); ismask → is_mask= |
AudioClip() | make_frame → frame_function= (from 2.1.0) |
ImageClip() | ismask → is_mask= |
CompositeVideoClip() | ismask → is_mask= |
ImageSequenceClip() | ismask → is_mask= |
VideoFileClip() | verbose gone |
concatenate_videoclips() | ismask → is_mask= |
clips_array() | cols_widths gone (2.x has cols_heights=) |
clip.write_videofile() | rewrite_audio gone; verbose drop it; logger=None silences the progress bar |
clip.write_gif() | program gone; opt gone; fuzz gone; verbose drop it; logger=None silences the progress bar; dispose gone; colors gone; tempfiles gone |
clip.write_images_sequence() | nameformat → name_format=; verbose gone; withmask → with_mask= |
clip.save_frame() | withmask → with_mask= |
audioclip.write_audiofile() | verbose drop it; logger=None silences the progress bar |
SubtitlesClip.in_subclip() | t_start → start_time=; t_end → end_time= |
How was this measured?
MoviePy 1.0.0, 1.0.1, 1.0.2, 1.0.3, 2.0.0, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1 were each installed from PyPI in their own environment (Python 3.11.18), and a probe listed every module file, the names of each importable module, and the members and parameters of every class, after import moviepy.editor where it exists (that import is what attaches resize, fadein and the other effect methods to the clips in 1.x). Members set in __init__ were read from real objects: a ColorClip, ImageClip, AudioClip, CompositeVideoClip, and a VideoFileClip and AudioFileClip of a one-second file written with the bundled ffmpeg.
Each rename was then run: the 1.x spelling in 1.0.3 and the 2.x spelling in 2.2.1 on the same two-second 64x48 clip (a moving gradient with a 440 Hz tone), comparing duration, size, fps, the frame at t=0.5, the mask frame and the loudest audio sample. Rows that did not come out identical say so. 1.x TextClip needs ImageMagick and could not be built here, so TextClip was run in 2.x only. 2.0.0.dev1 and dev2 (2020) were not installed.
Questions
How do I fix "'VideoFileClip' object has no attribute 'subclip'"?
MoviePy 2.0.0 (2024-11-20) renamed it: write clip.subclipped(start, end). The other methods changed the same way: set_duration, set_start, set_position and the rest are with_duration, with_start, with_position; resize, crop and rotate are resized, cropped and rotated. Run on a test clip, subclip(0.5, 1.5) in 1.0.3 and subclipped(0.5, 1.5) in 2.2.1 gave the same frames. To keep the old names: pip install "moviepy<2".
How do I fix "No module named 'moviepy.editor'"?
MoviePy 2.0.0 removed moviepy.editor. Write from moviepy import VideoFileClip, AudioFileClip, concatenate_videoclips (or from moviepy import *). Code written for 1.x then needs the renamed methods too, or pip install "moviepy==1.0.3".
How do I fix "'VideoFileClip' object has no attribute 'resize'" (or 'fx', 'fadein', 'volumex')?
In 1.x these were effect functions attached to the clip. In 2.x: clip.resized(0.5), clip.cropped(...), clip.rotated(angle, expand=True), clip.with_volume_scaled(0.5), clip.with_speed_scaled(2); and for every effect, clip.with_effects([vfx.FadeIn(1), vfx.MirrorX()]) with the effect classes from moviepy import vfx, afx. clip.fx(vfx.mirror_x) becomes clip.with_effects([vfx.MirrorX()]).
How do I fix "TextClip got an unexpected keyword argument 'fontsize'" or "multiple values for argument 'font'"?
In 2.x the first parameter of TextClip is font, a path to a font file, and the others were renamed: TextClip(text="hi", font="/path/DejaVuSans.ttf", font_size=20, color="white") ran in 2.2.1. txt is text and fontsize is font_size. TextClip("hi", font=...) raises "multiple values for argument 'font'" because "hi" lands on font.
How do I fix "write_videofile() got an unexpected keyword argument 'verbose'"?
2.x dropped verbose (and rewrite_audio) from write_videofile, and verbose from write_audiofile and write_gif. Remove the argument; logger=None silences the progress bar.
How do I fix "'ImageDraw' object has no attribute '_multiline_spacing'" in TextClip?
That is MoviePy 2.2.0 with Pillow 11.3.0: building a TextClip raised it here. 2.2.1, installed with the same Pillow, builds the same clip. pip install -U moviepy.
Why does moviepy.__version__ show the wrong version?
The attribute was not updated in three releases: 2.1.2 reports 2.1.1, and 2.2.0 and 2.2.1 report 2.1.2. Use pip show moviepy, or importlib.metadata.version("moviepy").
Sources
- The MoviePy releases on PyPI, installed and run; the release dates are PyPI's.
- MoviePy's own guide to updating from v1 to v2.
The same data as JSON: moviepy_names.json, licensed CC BY 4.0.
Related: "module 'cv2' has no attribute 'CascadeClassifier'" · "module 'PIL.Image' has no attribute 'ANTIALIAS'" · "module 'numpy' has no attribute 'float_'".