我有一个名为的 Python 文件my_python_file.py
,其中包括.doc
使用该python-docx
模块的文件。完美创建并且.doc
没有问题。当我构建.exe
我的脚本并尝试制作.doc
. 出现AssertionError
问题。
这是我的 exe 制造商代码(exe_maker.py
):
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 3, 'compressed': True, 'includes': ['lxml.etree', 'lxml._elementpath', 'gzip', 'docx']}},
windows = [{'script': "my_python_file.py"}],
zipfile = None,
)
似乎将 python 脚本移动到不同的位置会产生错误。
File "docx.pyc", line 1063, in savedocx
AssertionError
这是savedocx
行:
document = newdocument()
[...]
coreprops = coreproperties(title=title, subject=subject, creator=creator, keywords=keywords)
approps = appproperties()
contenttypes2 = contenttypes()
websettings2 = websettings()
wordrelationships2 = wordrelationships(relationships)
path_save = "C:\output"
savedocx(document, coreprops, approps, contenttypes2, websettings2, wordrelationships2, path_save)
savedox
写得很好,因为它不是文件时可以工作.exe
。
如何使docx
模块正常工作?制作 exe 时是否需要添加任何其他路径/变量?
提前致谢