我生成应用程序没有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
}
},
)
答案 0 :(得分: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))
答案 1 :(得分:0)
行id
中存在属性错误,可能会尝试cx_freeze .py到.exe转换器。