Moviepy: AttributeError: module 'moviepy.audio.fx.all' has no attribute 'audio_fadein'

Created on 18 Jun 2017  Â·  9Comments  Â·  Source: Zulko/moviepy

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:
2017-06-18 3

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)

audio environment

Most helpful comment

For everyone that has the same issue i solved it by modifying the selected __init__ file shown in the picture below:

File Location

Inside it there is a piece of code that import every function inside the fx folder:

__all__ = [name for _, name, _ in pkgutil.iter_modules(
    fx.__path__) if name != "all"]
for name in __all__:
    exec("from ..%s import %s" % (name, name))

Comment this block and import manually every function needed, like so:

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.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.mirror_x import mirror_x
from moviepy.video.fx.mirror_y import mirror_y
from moviepy.video.fx.resize import resize
#etc.

Do the same with the init placed in moviepy.audio.fx.all

All 9 comments

For everyone that has the same issue i solved it by modifying the selected __init__ file shown in the picture below:

File Location

Inside it there is a piece of code that import every function inside the fx folder:

__all__ = [name for _, name, _ in pkgutil.iter_modules(
    fx.__path__) if name != "all"]
for name in __all__:
    exec("from ..%s import %s" % (name, name))

Comment this block and import manually every function needed, like so:

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.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.mirror_x import mirror_x
from moviepy.video.fx.mirror_y import mirror_y
from moviepy.video.fx.resize import resize
#etc.

Do the same with the init placed in moviepy.audio.fx.all

I can vouch for ZiddyEng's answer, it worked perfectly for me.

I have followed the Instructions that you provide,but it still with the same issue.So,could you please provide more detailed operation instructions.

I am having the same issue :( but with pyinstaller

The recommendation kinda fix the issue, but I have another error now with volumex attribute not found.

Anyone knows a way to replace the original code with something less static that the whole import list?

I am having the same issue :( but with pyinstaller

The recommendation kinda fix the issue, but I have another error now with volumex attribute not found.

Anyone knows a way to replace the original code with something less static that the whole import list?

you can do with the ZiddyEng comment but with audio

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

and this is the full list of video:

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

@ZiddyEng 's solution works like a charm, no issues, but it is still a hack, not the proper solution, we should fix editor PyCharm(VSCode in my case).

Frankly this package list does not get updated quite often. It would be a whole less messier to import files by name rather than using exec, and also it would make packaging apps that rely on moviepy a lot easier.

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

The way of import the FXs described in this issue is deprecated, so I'm closing this...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Netherdrake picture Netherdrake  Â·  4Comments

TowelDude picture TowelDude  Â·  3Comments

PyB1l picture PyB1l  Â·  3Comments

skizzy picture skizzy  Â·  3Comments

tburrows13 picture tburrows13  Â·  3Comments