Error calling LibreOffice from Python

回眸只為那壹抹淺笑 提交于 2019-12-01 22:05:21

This is the code you should use:

subprocess.call(['soffice', '--headless', '--convert-to', 'txt:Text', 'document_to_convert.doc'])

This is the same line you posted, without the quotes around txt:Text.

Why are you seeing the error? Simply put: because soffice does not accept txt:"Text". It only accepts txt:Text.

Why is it working on the shell? Your shell implicitly removes quotes around arguments, so that the command that gets executed is actually:

soffice --headless --convert-to txt:Text document_to_convert.doc

Try running this command:

soffice --headless --convert-to txt:\"Text\" document_to_convert.doc

Quotes won't be removed and you'll see the Please verify input parameters message you are getting with Python.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!