moviepy打包错误的解决方法:module ‘moviepy.audio.fx.all‘ 和 TypeError: ‘module‘ object is not callable

错误描述

moviepy打包后运行,出现module ‘moviepy.audio.fx.all’ 和 TypeError: ‘module’ object is not callable等错误信息,找到网上的方法【print(“from moviepy.audio.fx import %s” % (name))】却失败,根据他这个方法举一反三,我直接【print(“from …%s import %s” % (name, name))】居然解决了,下面是具体修改方法。

操作方法

1.打开C:\Users\xxx\AppData\Local\Programs\Python\Python37\Lib\site-packages\moviepy\video\fx\all_init_.py

看到如下代码:

"""
Loads all the fx !
Usage:
import moviepy.video.fx.all as vfx
clip = vfx.resize(some_clip, width=400)
clip = vfx.mirror_x(some_clip)
"""

import pkgutil

import moviepy.video.fx as fx

__all__ = [name for _, name, _ in pkgutil.iter_modules(
    fx.__path__) if name != "all"]

for name in __all__:
    exec("from ..%s import %s" % (name, name))
    

修改代码为:

"""
Loads all the fx !
Usage:
import moviepy.video.fx.all as vfx
clip = vfx.resize(some_clip, width=400)
clip = vfx.mirror_x(some_clip)
"""

import pkgutil

import moviepy.video.fx as fx

__all__ = [name for _, name, _ in pkgutil.iter_modules(
    fx.__path__) if name != "all"]

for name in __all__:
    #exec("from ..%s import %s" % (name, name))
    print("from ..%s import %s" % (name, name))
    

运行后得到:

from ..accel_decel import accel_decel
from ..blackwhite import blackwhite
from ..blink import blink
from ..colorx import colorx
from ..crop import crop
from ..even_size import even_size
from ..fadein import fadein
from ..fadeout import fadeout
from ..freeze import freeze
from ..freeze_region import freeze_region
from ..gamma_corr import gamma_corr
from ..headblur import headblur
from ..invert_colors import invert_colors
from ..loop import loop
from ..lum_contrast import lum_contrast
from ..make_loopable import make_loopable
from ..margin import margin
from ..mask_and import mask_and
from ..mask_color import mask_color
from ..mask_or import mask_or
from ..mirror_x import mirror_x
from ..mirror_y import mirror_y
from ..painting import painting
from ..resize import resize
from ..rotate import rotate
from ..scroll import scroll
from ..speedx import speedx
from ..supersample import supersample
from ..time_mirror import time_mirror
from ..time_symmetrize import time_symmetrize

将其直接复制到程序里,并注释掉部分语句变成:

"""
Loads all the fx !
Usage:
import moviepy.video.fx.all as vfx
clip = vfx.resize(some_clip, width=400)
clip = vfx.mirror_x(some_clip)
"""

import pkgutil

import moviepy.video.fx as fx

__all__ = [name for _, name, _ in pkgutil.iter_modules(
    fx.__path__) if name != "all"]

#for name in __all__:
    #exec("from ..%s import %s" % (name, name))
    #print("from moviepy.audio.fx import %s" % (name))
    #print("from ..%s import %s" % (name, name))
    #exec("from moviepy.video.fx import %s" % (name))
from ..accel_decel import accel_decel
from ..blackwhite import blackwhite
from ..blink import blink
from ..colorx import colorx
from ..crop import crop
from ..even_size import even_size
from ..fadein import fadein
from ..fadeout import fadeout
from ..freeze import freeze
from ..freeze_region import freeze_region
from ..gamma_corr import gamma_corr
from ..headblur import headblur
from ..invert_colors import invert_colors
from ..loop import loop
from ..lum_contrast import lum_contrast
from ..make_loopable import make_loopable
from ..margin import margin
from ..mask_and import mask_and
from ..mask_color import mask_color
from ..mask_or import mask_or
from ..mirror_x import mirror_x
from ..mirror_y import mirror_y
from ..painting import painting
from ..resize import resize
from ..rotate import rotate
from ..scroll import scroll
from ..speedx import speedx
from ..supersample import supersample
from ..time_mirror import time_mirror
from ..time_symmetrize import time_symmetrize

保存即可

然后同样的方法修改另一个管音频的文件:
C:\Users\xxx\AppData\Local\Programs\Python\Python37\Lib\site-packages\moviepy\audio\fx\all_init_.py
用和上面一样的方法去操作就行啦。

你可能感兴趣的:(python,深度学习,javascript)