moviepy: AttributeError: module 'moviepy.audio.fx.all' has no attribute 'audio_fadein'
I have used cx_freeze to build a python project into a single folder with an .exe and it’s dependencies, but when I run the .exe I get the error: AttributeError: module 'moviepy.audio.fx.all' has no attribute 'audio_fadein'
I have tried both from moviepy.editor import *
and also from moviepy.video.io.VideoFileClip import VideoFileClip
and here is the python code:
pygame.display.set_mode((854, 480), pygame.NOFRAME)
pygame.display.set_caption('©2017 CherryByte™ Software')
pygame.mouse.set_visible(False)
logo = VideoFileClip('CherryByte Logo.mp4')
logo.preview()
pygame.mouse.set_visible(True)
It seems to run fine from the IDE (PyCharm) but once built, it seems to fail. Here is a shot of the Traceback:
Python version 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] Version info. sys.version_info(major=3, minor=6, micro=1, releaselevel=‘final’, serial=0)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 9
- Comments: 26 (1 by maintainers)
For everyone that has the same issue i solved it by modifying the selected init file shown in the picture below:
Inside it there is a piece of code that import every function inside the fx folder:
Comment this block and import manually every function needed, like so:
Do the same with the init placed in moviepy.audio.fx.all
you can do with the ZiddyEng comment but with audio
and this is the full list of video:
For me worked this: comment all what there is inside of: C:\Users\freddydev\AppData\Local\Programs\Python\Python37\Lib\site-packages\moviepy\video\fx\all_init_.py and add it: from moviepy.video.io.VideoFileClip import VideoFileClip from moviepy.video.VideoClip import ImageClip from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip from moviepy.audio.io.AudioFileClip import AudioFileClip from moviepy.audio.AudioClip import AudioClip from moviepy.editor import concatenate_videoclips,concatenate_audioclips,TextClip,CompositeVideoClip from moviepy.video.fx.accel_decel import accel_decel from moviepy.video.fx.blackwhite import blackwhite from moviepy.video.fx.blink import blink from moviepy.video.fx.colorx import colorx from moviepy.video.fx.crop import crop from moviepy.video.fx.even_size import even_size from moviepy.video.fx.fadein import fadein from moviepy.video.fx.fadeout import fadeout from moviepy.video.fx.freeze import freeze from moviepy.video.fx.freeze_region import freeze_region from moviepy.video.fx.gamma_corr import gamma_corr from moviepy.video.fx.headblur import headblur from moviepy.video.fx.invert_colors import invert_colors from moviepy.video.fx.loop import loop from moviepy.video.fx.lum_contrast import lum_contrast from moviepy.video.fx.make_loopable import make_loopable from moviepy.video.fx.margin import margin from moviepy.video.fx.mask_and import mask_and from moviepy.video.fx.mask_color import mask_color from moviepy.video.fx.mask_or import mask_or from moviepy.video.fx.mirror_x import mirror_x from moviepy.video.fx.mirror_y import mirror_y from moviepy.video.fx.painting import painting from moviepy.video.fx.resize import resize from moviepy.video.fx.rotate import rotate from moviepy.video.fx.scroll import scroll from moviepy.video.fx.speedx import speedx from moviepy.video.fx.supersample import supersample from moviepy.video.fx.time_mirror import time_mirror from moviepy.video.fx.time_symmetrize import time_symmetrize
Also here comment all the content of: C:\Users\freddydev\AppData\Local\Programs\Python\Python37\Lib\site-packages\moviepy\audio\fx\all_init_.py and add this: from moviepy.audio.fx.audio_fadein import audio_fadein from moviepy.audio.fx.audio_fadeout import audio_fadeout from moviepy.audio.fx.audio_left_right import audio_left_right from moviepy.audio.fx.audio_loop import audio_loop from moviepy.audio.fx.audio_normalize import audio_normalize from moviepy.audio.fx.volumex import volumex
Now you will get your .exe without problems but in my case after concatenate several videos there was a wrong encoding and I got I bad video, only some videos I could watch fine but another were difuse.
I also use pyinstaller to freeze and it is pretty inconvenient to edit the library rather than my own code. What is worked for me is to import only what I am gonna use manually in my own code e.g.;
from moviepy.video.VideoClip import VideoClip
from moviepy.video.fx.resize import resize
VideoClip.resize = resize
Big high five. It works. What I did was, I copy pasted anhhna’s comment. Then I covert it to an exe using AUTOPYTOEXE module. You can easily download this by pip though. This is my imports looks like now.
from moviepy.video.io.VideoFileClip import VideoFileClip from moviepy.video.VideoClip import ImageClip from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip from moviepy.audio.io.AudioFileClip import AudioFileClip from moviepy.audio.AudioClip import AudioClip from moviepy.editor import concatenate_videoclips,concatenate_audioclips,TextClip,CompositeVideoClip from moviepy.video.fx.accel_decel import accel_decel from moviepy.video.fx.blackwhite import blackwhite from moviepy.video.fx.blink import blink from moviepy.video.fx.colorx import colorx from moviepy.video.fx.crop import crop from moviepy.video.fx.even_size import even_size from moviepy.video.fx.fadein import fadein from moviepy.video.fx.fadeout import fadeout from moviepy.video.fx.freeze import freeze from moviepy.video.fx.freeze_region import freeze_region from moviepy.video.fx.gamma_corr import gamma_corr from moviepy.video.fx.headblur import headblur from moviepy.video.fx.invert_colors import invert_colors from moviepy.video.fx.loop import loop from moviepy.video.fx.lum_contrast import lum_contrast from moviepy.video.fx.make_loopable import make_loopable from moviepy.video.fx.margin import margin from moviepy.video.fx.mask_and import mask_and from moviepy.video.fx.mask_color import mask_color from moviepy.video.fx.mask_or import mask_or from moviepy.video.fx.mirror_x import mirror_x from moviepy.video.fx.mirror_y import mirror_y from moviepy.video.fx.painting import painting from moviepy.video.fx.resize import resize from moviepy.video.fx.rotate import rotate from moviepy.video.fx.scroll import scroll from moviepy.video.fx.speedx import speedx from moviepy.video.fx.supersample import supersample from moviepy.video.fx.time_mirror import time_mirror from moviepy.video.fx.time_symmetrize import time_symmetrize
from moviepy.audio.fx.audio_fadein import audio_fadein from moviepy.audio.fx.audio_fadeout import audio_fadeout from moviepy.audio.fx.audio_left_right import audio_left_right from moviepy.audio.fx.audio_loop import audio_loop from moviepy.audio.fx.audio_normalize import audio_normalize from moviepy.audio.fx.volumex import volumex