py2exe和moviepy属性错误

问题描述 投票:1回答:2

我生成应用程序没有py2exe问题。但是,当我执行.exe时,它会抛出下一个回溯:

Traceback (most recent call last):
  File "editor.py", line 25, in <module>
  File "moviepy\editor.pyo", line 72, in <module>

  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'audio_fadein'

我以前使用py2exe成功的结果,但现在我使用moviepy我无法使它工作。这是我的setup.py,执行python setup.py py2exe时没有错误:

from distutils.core import setup
from py2exe.build_exe import py2exe
import os
from distutils.filelist import findall
import matplotlib

datafiles = ['logo.png', 'Lower Brand.png', "icon.ico"]

matplotlibdatadir = matplotlib.get_data_path()
matplotlibdata = findall(matplotlibdatadir)
matplotlibdata_files = []

for f in matplotlibdata:
    dirname = os.path.join('matplotlibdata', f[len(matplotlibdatadir)+1:])
    matplotlibdata_files.append((os.path.split(dirname)[0], [f]))

mpl = matplotlib.get_py2exe_datafiles()
datafiles.extend(mpl)


setup(
    name='VTE',
    description="Video Test Editor",
    version="1.0",
    author="David Rodriguez",


    data_files=datafiles,

    console=[
        {
            'script':'videoeditor.py',
            'icon_resources': [(1, r"icon.ico")]
        }
    ],
    options={ 'py2exe': {
                'skip_archive':True,
                'includes': ['sip', 'moviepy'],
                'excludes': ['_gtkagg', '_tkagg', '_ssl'],
                'optimize': 2,
                'unbuffered': True
                }
            },
    )
python py2exe moviepy
2个回答
1
投票

moviepy使用exec进行大量动态导入,这会导致py2exe运行。我通过手动将整个moviepy模块复制到build文件夹来解决了这个问题:

import moviepy
from pathlib import Path
import shutil

moviepy_path= Path(moviepy.__file__).parent
target_path= Path(sys.argv[0]).parent / 'build' / 'exe.win32-3.4' / 'moviepy'
shutil.rmtree(str(target_path))
shutil.copytree(str(moviepy_path), str(target_path))

0
投票

'includes': ['sip', 'moviepy'],中有属性错误,也许尝试cx_freeze .py到.exe转换器。

© www.soinside.com 2019 - 2024. All rights reserved.