无法使用代码运行子进程,commond 在终端上工作

编程入门 行业动态 更新时间:2024-10-25 22:24:48
本文介绍了无法使用代码运行子进程,commond 在终端上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用 LibreOffice 从 .docx 文件生成一个 PDF.这是我的子进程命令:

I am generating a PDF from .docx file using LibreOffice. This is my sub-process command:

output = subprocess.call('libreoffice --headless --convert-to pdf:writer_pdf_Export' + out_folder + ' ' + input_docx + ' -env:UserInstallation=file:///tmp/LibreOffice_Conversion_${USER}',shell=True)

当我在终端上运行它时 PDF 生成正确,但是当我调用这个子进程时.它给出了 127 错误代码.

When I run this on terminal PDF is generating properly but when I call this sub-process. It gives 127 error code.

推荐答案

使用下面的代码你可以得到你想要的结果.

Using the below code you can get your expected result.

import subprocess out_folder = '/var/www/html/SocketQueue' input_docx='/home/dhamo/Downloads/CNGroup_estimates.docx' subprocess.call(['libreoffice', '--headless', '--convert-to','pdf:writer_pdf_Export', '--outdir', out_folder, input_docx, '-env:UserInstallation=file:///tmp/LibreOffice_Conversion_${USER}'])

更多推荐

无法使用代码运行子进程,commond 在终端上工作

本文发布于:2023-10-28 00:47:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535009.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:终端   进程   代码   工作   commond

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!