pyinstaller打包exe带movies库闪退问题

问题1:pyinstaller不认exec这种方法

在python环境\Lib\site-packages\moviepy\audio\fx\all的__init__.py文件下:

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

打印出需要导入的库

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__:
    print("from ..%s import %s" % (name, name))
    exec("from ..%s import %s" % (name, name))

注释exec内容,手动导入打印出需求库(video\fx\all的__init__.py同样配置)

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__:
#     print("from ..%s import %s" % (name, name))
#     exec("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

问题2:打包成exe,运行报错(下图)

FileNotFoundError:Package has no location <module 'imageio_ffmpeg.biaries'(namespace)>

工程目录下新建hook-imageio_ffmpeg.py文件

from PyInstaller.utils.hooks import collect_all
datas, binaries, hiddenimports = collect_all('imageio_ffmpeg')

重新打包代码

pyinstaller --onefile --additional-hooks-dir=. you_script.py

附:numpy打包exe问题

解:部分python版本报错,小编使用python==3.8,各位可以参考一下

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值