简体   繁体   English

UNOCONV 无法在 CentOS 上转换 PHP 中的文件

[英]UNOCONV failing to convert files in PHP on CentOS

I have UNOCONV library installed on my CentOS 7.3.16.11.我在 CentOS 7.3.16.11 上安装了 UNOCONV 库。 When I run file conversion from CLI it works fine, and I'm getting PDF document back:当我从 CLI 运行文件转换时,它工作正常,并且我正在取回 PDF 文档:
unoconv -d spreadsheet --format=pdf -o temp/ ./document.docx

But when I try to execute it from PHP 5.6.29, it doesn't give me any output PDF.但是当我尝试从 PHP 5.6.29 执行它时,它没有给我任何输出 PDF。 I'm getting an error from Python environment:我从 Python 环境中收到错误消息:
Traceback (most recent call last): File "/usr/bin/unoconv", line 1196, in <module> run() File "/usr/bin/unoconv", line 1108, in run office_environ(of) File "/usr/bin/unoconv", line 202, in office_environ os.environ['PATH'] = realpath(office.basepath, 'program') + os.pathsep + os.environ['PATH'] File "/usr/lib64/python2.7/UserDict.py", line 23, in \\__getitem__ raise KeyError(key) KeyError: 'PATH'

Checked the paths in my environment with:使用以下命令检查了我环境中的路径:
echo $PATH
The output is:输出是:
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/username/.local/bin:/home/username/bin

What can be wrong with running UNOCONV from php?从 php 运行 UNOCONV 有什么问题?

Beside figuring out how to set PATH properly while using php you may hack the unoconv script and change line 1174 from除了弄清楚如何在使用 php 时正确设置 PATH 之外,您还可以破解 unoconv 脚本并将第 1174 行从

os.environ['PATH'] = realpath(office.basepath, 'program') + os.pathsep + os.environ['PATH']

to

os.environ['PATH'] = realpath(office.basepath, 'program') + os.pathsep + os.environ['PATH'] if 'PATH' in os.environ.keys() else ''

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM