[英]Failed to Open Display error while running python subprocess and Libreoffice 6.2 in CentOS6
我需要运行Libreoffice --covert-to
to 将 excel 文件转换为 html 页面。 当前代码在 Windows 机器中运行良好。 但是在 AWS、CentOS6 中,它会产生错误“无法打开显示” 。 这是我的代码
import subprocess
cwdir = '/opt/libreoffice6.2/program'
excel_path = '/home/ec2-user/PythonCode/testing/Book1.xlsx'
dest_path = '/home/ec2-user/PythonCode/testing'
html_command = ["soffice", "--headless", "--convert-to", "html", "--outdir",
dest_path, excel_path]
subprocess.run(html_command, shell=True, cwd=cwdir)`
我能够通过一些小的更改将 excel 文件转换为 html 文件。 列表中的值不起作用,因此我必须将soffice convert-to
查询作为字符串值提供,该文件夹包含输入 excel 文件和目标文件夹,其中要存储的 html 文件必须不同。
import subprocess
cwdir = '/opt/libreoffice6.2/program'
excel_path = '/home/ec2-user/PythonCode/testing/Book1.xlsx'
dest_path = '/home/ec2-user/PythonCode/testing/output'
html_command = r"soffice --headless --convert-to html --outdir " + " " + dest_path + " " + excel_path
subprocess.run(html_command, shell=True, cwd=cwdir)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.