栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

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

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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:UsersxxxAppDataLocalProgramsPythonPython37Libsite-packagesmoviepyvideofxall_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:UsersxxxAppDataLocalProgramsPythonPython37Libsite-packagesmoviepyaudiofxall_init_.py
用和上面一样的方法去操作就行啦。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1017833.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号