本文介绍了无法使用代码运行子进程,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 在终端上工作
发布评论