Python-使用 docx2pdf import Convert 将 docx 转换为 pdf,但抛出错误 AttributeError: Word.Application.Documents
我正在尝试使用转换方法将 .docx 转换为 pdf。早些时候它可以工作,但现在我在输出中看到错误。请建议
#Converting docx to pdf format
from docx2pdf import convert
# Bulk Conversion
convert(r'C:\Users\ABC\',r'C:\Users\ABC\New\')
输出:AttributeError:Word.Application.Documents 在此处输入图片说明
i am trying to convert to .docx to pdf using convert method. Earlier it was working but now i see error in the output.Kindly suggest
#Converting docx to pdf format
from docx2pdf import convert
# Bulk Conversion
convert(r'C:\Users\ABC\',r'C:\Users\ABC\New\')
Output:AttributeError: Word.Application.Documents
enter image description here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来您遇到了路径问题,从文档中我可以看到
您可以尝试更改路径吗?
It looks like you are having a path issue, from the documentation I can see
Can you try to maybe change the path?
不要仅导入
convert
函数,导入整个类docx2pdf
。我的猜测是它使用的win32
依赖项在运行时获取 .docx 文件属性。因此,仅在批量转换时导入convert
可能会导致冲突。我最近在
docx2pdf
之上构建了一个用于批量转换的 clirocketpdf
,并且我必须导入整个类才能操作tqdm
等进程代码>.Do not import only
convert
function, import the whole classdocx2pdf
. My guess is thewin32
dependency it uses gets the .docx file attributes on runtime. So importingconvert
only on bulk conversions may be causing the conflict.I recently built a cli
rocketpdf
for bulk conversions like this on top ofdocx2pdf
and I had to import the whole class in order to manipulate some processes liketqdm
.