Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
JSkorpio05 opened this issue Jun 18, 2017 · 26 comments
Labels
audio Related to AudioClip, or handling of audio in general. environment Using moviepy with, or issues possibly stemming from specific OS/platforms/environments.

Comments

@JSkorpio05
Copy link

JSkorpio05 commented Jun 18, 2017

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)

@keikoro keikoro added the audio Related to AudioClip, or handling of audio in general. label Nov 25, 2017
@ZiddyEng
Copy link

ZiddyEng commented Sep 5, 2018

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

@MahmoudThePeltist
Copy link

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

@liuwen1996
Copy link

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

@eried
Copy link

eried commented Nov 20, 2018

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?

@anhhna
Copy link

anhhna commented Nov 30, 2018

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

@ishandutta2007
Copy link
Contributor

@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).

@Overdrivr
Copy link
Collaborator

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.

@tanisc
Copy link

tanisc commented Apr 18, 2020

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

@keikoro keikoro added the environment Using moviepy with, or issues possibly stemming from specific OS/platforms/environments. label Oct 8, 2020
@mondeja
Copy link
Collaborator

mondeja commented Jan 13, 2021

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

@mondeja mondeja closed this as completed Jan 13, 2021
@saifullah9002
Copy link

saifullah9002 commented Oct 3, 2021

Well the @ZiddyEng 's solution worked but I got new error, I am using pyinstaller

File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "moviepy\editor.py", line 48, in
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "moviepy\video\fx_init
.py", line 5, in
NameError: name 'pkgutil' is not defined

But I found the solution:

step 1:
Python 3\Lib\site-packages\moviepy\video\fx\all_init_.py

  • comment all the code and the following lines:

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

step 2:
Python 3\Lib\site-packages\moviepy\audio\fx\all_init_.py

  • comment all its code and add the lines below:

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 if you build exe with pyinstaller it fixes the error not sure if it works with cx_freeze.

@wanghaisheng
Copy link

@Zulko

from moviepy.editor import VideoFileClip, AudioFileClip
import moviepy.video.fx.all as vfx

still got same issue pyinstaller

@saifullah9002
Copy link

@wanghaisheng Follow the steps above your comments. don't edit in the virtual enviroment.

@wanghaisheng
Copy link

@saifullah9002 can you just push these code to master branch and got merged?

@wanghaisheng
Copy link

@saifullah9002 there is no all_init_.py in moviepy 1.0.3 version

Python 3\Lib\site-packages\moviepy\video\fx\all_init_.py

@keikoro
Copy link
Collaborator

keikoro commented Nov 5, 2021

@wanghaisheng Please open a new issue describing the problem you are having instead of commenting on an old, closed one that might or might not be related, thank you.

@wanghaisheng
Copy link

@keikoro I am curious why this same issue still exist

@keikoro
Copy link
Collaborator

keikoro commented Nov 5, 2021

@wanghaisheng The original issue didn't even mention pyinstaller, other people just added onto it.

Also, you can always refer to an older, (possibly) related issue by mentioning its ticket no. in your own issue. This will create a link between the two for easy navigation.

@Vikasitha444
Copy link

I had the same situation. I got this error.

Traceback (most recent call last):
File "Claro.py", line 14, in
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "moviepy\editor.py", line 87, in
File "", line 1, in
AttributeError: module 'moviepy.audio.fx.all' has no attribute 'audio_fadein'

I was wondering how to fix this? And anyone has any idea?

@keikoro
Copy link
Collaborator

keikoro commented Nov 10, 2021

You can obviously comment on closed issues, I was mainly making you aware that commenting here won't get you as much attention because fewer people will see it (I only did because I'm a maintainer, who gets notifications). Of the people who do, not everyone will bother to read through all the old content to try to figure how the new comments relate, because old, closed issues naturally tend to get new comments that don't have anything to do with the original post.

As said by a fellow maintainer up-thread, some of the info given by OP in 2017 isn't applicable anymore to how things are handled in recent versions of the library, that's why the issue was closed. If you continue to comment here, your issue either doesn't match OP's issue (with outdated code) exactly, in which case you ought to open a new one; or, you are using outdated versions of MoviePy, in which case you should upgrade.

@Vikasitha444
Copy link

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

@wanghaisheng
Copy link

@Vikasitha444 where do you put my imports to which file

@orkenstein
Copy link

@Zenahr
Copy link

Zenahr commented Dec 5, 2021

@Vikasitha444 's solution solved my problem while using PyInstaller to compile executables.
@Zulko Perhaps it might be useful to have a short note referencing this issue in the readme or somewhere else regarding executable compilation so this issue isn't necroed again.

@alcarazolabs
Copy link

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.

@irfan-ssh
Copy link

still same error

@alexkutsan
Copy link

I am also facing this issue:

root@2eee84d9d145:/app# python3 -m pip install moviepy==1.0.3
Collecting moviepy==1.0.3
  Using cached moviepy-1.0.3-py3-none-any.whl
Requirement already satisfied: decorator<5.0,>=4.0.2 in /usr/local/lib/python3.8/dist-packages (from moviepy==1.0.3) (4.4.2)
Requirement already satisfied: proglog<=1.0.0 in /usr/local/lib/python3.8/dist-packages (from moviepy==1.0.3) (0.1.10)
Requirement already satisfied: requests<3.0,>=2.8.1 in /usr/local/lib/python3.8/dist-packages (from moviepy==1.0.3) (2.28.2)
Requirement already satisfied: tqdm<5.0,>=4.11.2 in /usr/local/lib/python3.8/dist-packages (from moviepy==1.0.3) (4.65.0)
Requirement already satisfied: numpy>=1.17.3 in /usr/local/lib/python3.8/dist-packages (from moviepy==1.0.3) (1.23.5)
Requirement already satisfied: imageio<3.0,>=2.5 in /usr/local/lib/python3.8/dist-packages (from moviepy==1.0.3) (2.27.0)
Requirement already satisfied: imageio-ffmpeg>=0.2.0 in /usr/local/lib/python3.8/dist-packages (from moviepy==1.0.3) (0.4.8)
Requirement already satisfied: pillow>=8.3.2 in /usr/local/lib/python3.8/dist-packages (from imageio<3.0,>=2.5->moviepy==1.0.3) (9.5.0)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.8/dist-packages (from requests<3.0,>=2.8.1->moviepy==1.0.3) (3.1.0)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.8/dist-packages (from requests<3.0,>=2.8.1->moviepy==1.0.3) (3.4)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.8/dist-packages (from requests<3.0,>=2.8.1->moviepy==1.0.3) (1.26.15)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.8/dist-packages (from requests<3.0,>=2.8.1->moviepy==1.0.3) (2022.12.7)
Installing collected packages: moviepy
Successfully installed moviepy-1.0.3
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@2eee84d9d145:/app# python3 -c "from moviepy.audio.fx.multiply_volume import multiply_volume"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'moviepy.audio.fx.multiply_volume'
root@2eee84d9d145:/app# python3 -m pip uninstall  moviepy 
Found existing installation: moviepy 1.0.3
Uninstalling moviepy-1.0.3:
  Would remove:
    /usr/local/lib/python3.8/dist-packages/moviepy-1.0.3.dist-info/*
    /usr/local/lib/python3.8/dist-packages/moviepy/*
Proceed (Y/n)? y
  Successfully uninstalled moviepy-1.0.3
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@2eee84d9d145:/app# python3 -m pip install moviepy==1.0.3 
Collecting moviepy==1.0.3
  Using cached moviepy-1.0.3-py3-none-any.whl
Requirement already satisfied: decorator<5.0,>=4.0.2 in /usr/local/lib/python3.8/dist-packages (from moviepy==1.0.3) (4.4.2)
Requirement already satisfied: proglog<=1.0.0 in /usr/local/lib/python3.8/dist-packages (from moviepy==1.0.3) (0.1.10)
Requirement already satisfied: requests<3.0,>=2.8.1 in /usr/local/lib/python3.8/dist-packages (from moviepy==1.0.3) (2.28.2)
Requirement already satisfied: tqdm<5.0,>=4.11.2 in /usr/local/lib/python3.8/dist-packages (from moviepy==1.0.3) (4.65.0)
Requirement already satisfied: numpy>=1.17.3 in /usr/local/lib/python3.8/dist-packages (from moviepy==1.0.3) (1.23.5)
Requirement already satisfied: imageio<3.0,>=2.5 in /usr/local/lib/python3.8/dist-packages (from moviepy==1.0.3) (2.27.0)
Requirement already satisfied: imageio-ffmpeg>=0.2.0 in /usr/local/lib/python3.8/dist-packages (from moviepy==1.0.3) (0.4.8)
Requirement already satisfied: pillow>=8.3.2 in /usr/local/lib/python3.8/dist-packages (from imageio<3.0,>=2.5->moviepy==1.0.3) (9.5.0)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.8/dist-packages (from requests<3.0,>=2.8.1->moviepy==1.0.3) (3.1.0)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.8/dist-packages (from requests<3.0,>=2.8.1->moviepy==1.0.3) (3.4)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.8/dist-packages (from requests<3.0,>=2.8.1->moviepy==1.0.3) (1.26.15)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.8/dist-packages (from requests<3.0,>=2.8.1->moviepy==1.0.3) (2022.12.7)
Installing collected packages: moviepy
Successfully installed moviepy-1.0.3
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

root@2eee84d9d145:/app# python3 -c "from moviepy.audio.fx.multiply_volume import multiply_volume"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'moviepy.audio.fx.multiply_volume'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audio Related to AudioClip, or handling of audio in general. environment Using moviepy with, or issues possibly stemming from specific OS/platforms/environments.
Projects
None yet
Development

No branches or pull requests