我在 Python 中的 libreoffice 遇到了最令人沮丧的问题
当我在终端中运行以下命令时,我完全没有问题,pdf 文件会在我想要的地方生成,生活很美好:
cd /Applications/LibreOffice.app/Contents/MacOS/
./soffice --convert-to pdf --outdir {output_folder} {path_to_docx_file}/{title}.docx
但是,当我尝试将其添加到我的 python 脚本时:
SOFFICE = r'/Applications/LibreOffice.app/Contents/MacOS/soffice'
subprocess.Popen([SOFFICE, "--convert-to", "pdf", "--outdir", "{output_folder} ", "{path_to_docx_file}/{title}.docx"])
我收到一条错误消息:
我已经尝试打开所有二进制文件和文件的所有权限,但这在 python 脚本中仍然不起作用。我究竟做错了什么?
最佳答案
对我来说,这只是缺少“libreoffice-writer”包的问题。因此,如果您使用的是 Debian,请执行以下操作:
关于python - 在 python 中使用 soffice,命令在终端中工作但不在 Python 子进程中工作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37772250/