1

我使用 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
                }
            },
    )
4

2 回答 2

1

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

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))
于 2017-03-13T14:27:57.523 回答
0

行中有一个属性错误'includes': ['sip', 'moviepy'],,可以尝试 cx_freeze .py 到 .exe 转换器。

于 2016-01-25T11:43:31.697 回答