moviepy应用pyinstaller打包后执行报错No module named imageio,no attribute audio-fadein

moviepy应用pyinstaller打包后执行报错AttributeError: module ‘moviepy.audio.fx.all’ has no attribute ‘audio_fadein’,ModuleNotFoundError: No module named ‘imageio’

首先下载pyinstaller包,这个网上教程很多,就不多赘述。

ModuleNotFoundError: No module named ‘imageio’

发生这个错误的环境是:我在pycharm外部工具Enternal Tools添加pyinstaller.exe(具体教程百度很多),然后我添加的参数是-F。结果是打包的时候有一些警告,但还是打包成功了。我运行exe文件就报错:
Traceback (most recent call last):
File “main_pane2.py”, line 9, in
File “i:\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py”, line 623, in exec_module
exec(bytecode, module.dict)
File “site-packages\moviepy\editor.py”, line 24, in
ModuleNotFoundError: No module named 'imageio’
[1800] Failed to execute script main_pane2
我花了大量时间网上各种找资料还是不能解决。

AttributeError: module ‘moviepy.audio.fx.all’ has no attribute ‘audio_fadein’

正当我要放弃的时候,准备死马当活马医再试一下。于是我在pycharm终端Terminal使用pyinstaller打包。首先转到打包文件对应的路径下,然后输入pyinstaller.exe -F xxx.py 。打包成功后运行exe报错:

AttributeError: module ‘moviepy.audio.fx.all’ has no attribute 'audio_fadein’
[9272] Failed to execute script main_pane2

然后网上找资料发现了解决方法,参考
https://blog.csdn.net/LaoYuanPython/article/details/105346224
https://wqian.net/blog/2020/0319-index.html

最终解决方法是更改moviepy\video\fx\all_init_.py


```python

"""
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))

from moviepy.video.fx.crop import crop
from moviepy.video.fx.fadein import fadein
from moviepy.video.fx.fadeout import fadeout
#from moviepy.video.fx.left_right import left_right
from moviepy.video.fx.margin import margin
from moviepy.video.fx.loop import loop
from moviepy.video.fx.invert_colors import invert_colors
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.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

更改moviepy\audio\fx\all_init_.py

```python


"""
Loads all the fx !
Usage:
import moviepy.audio.fx.all as afx
audio_clip = afx.volume_x(some_clip, .5)
"""

import pkgutil

import moviepy.audio.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))

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

打包好的exe文件是可以正常运行的。

但是,我想把exe文件运行时的黑色控制台去掉,于是我在终端输入pyinstaller.exe -F -c xxx.py 。exe文件可以成功打包,但是运行之后闪退,也查看不了报错原因。目前这个问题还没得到解决。

你可能感兴趣的:(PyQt5)