python - .doc 到 pdf 使用 python 错误
问题描述
我正在尝试使用python将word文档转换为PDF。目前在python 3.8上。
import sys
import os
import comtypes.client
wdFormatPDF = 17
in_file = os.path.abspath(sys.argv[1])
out_file = os.path.abspath(sys.argv[2])
word = comtypes.client.CreateObject('Word.Application')
doc = word.Documents.Open(in_file)
doc.SaveAs(out_file, FileFormat=wdFormatPDF)
doc.Close()
word.Quit()
上面的代码回答了我的问题,但是当我将它部署到 VM 并使用调度程序远程运行它时,它只能在我的机器上运行,我得到以下错误
File "File Name", line 10, in <module>
word = comtypes.client.CreateObject('Word.Application')
File "Path", init__.py",line1225, in CoCreateInstance
----------------------------------------------------
File"_ctypes/callproc.c",line 930, in getResult
PermissionError:[WinError -2147024891] Access is denied
仅供参考,单词已安装在 VM 上
谢谢
解决方案
推荐阅读
- matlab - 用大分数缩短 MATLAB 方程
- mysql - 是否有查询以了解是否已为 mysql 用户授予特定权限?
- java - 表达式树的中缀符号,递归方法
- python - Python,将元素添加到字典
- android - 如何在 Android Studio 中只调试我的代码
- spring - Spring Application Context添加bean以检索密码
- python - 将纪元时间时间戳转换为当前时间戳python
- android - 带有 Google 身份验证用户的 Firebase 查询
- python - 使用python将api数据保存到json文件中
- mongoose - 我需要从满足某些条件的对象数组中找到对象