目的:MS Officeのコードが使用さ改宗者PPTは(エラーが発生した)
Windowsサーバにインストールされていない:
from subprocess import Popen, PIPE
import time
def convert(src, dst):
d = {'src': src, 'dst': dst}
commands = [
'/usr/bin/docsplit pdf --output %(dst)s %(src)s' % d,
'oowriter --headless -convert-to pdf:writer_pdf_Export %(dst)s %(src)s' % d,
]
for i in range(len(commands)):
command = commands[i]
st = time.time()
process = Popen(command, stdout=PIPE, stderr=PIPE, shell=True) # I am aware of consequences of using `shell=True`
out, err = process.communicate()
errcode = process.returncode
if errcode != 0:
raise Exception(err)
en = time.time() - st
print ('Command %s: Completed in %s seconds' % (str(i+1), str(round(en, 2))))
if __name__ == '__main__':
src = 'C:\xxx\ppt'
dst = 'C:\xxx\ppt\destination'
convert(src, dst)
シナリオのpython 3.6.1を使用してPDFにPPTを変換しますエラーが発生しました:
Traceback (most recent call last):
File "C:/PythonFolder/ppt_to_pdf.py", line 134, in <module>
convert(src, dst)
File "C:/PythonFolder/ppt_to_pdf.py", line 123, in convert
process = Popen(command, stdout=PIPE, stderr=PIPE, shell=True) # I am aware of consequences of using `shell=True`
File "C:\Python 3.6.1\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Python 3.6.1\lib\subprocess.py", line 990, in _execute_child
startupinfo)
ValueError: embedded null character
このエラーを解決する方法はありますか? この場合に役立つその他のPythonライブラリ。
WindowsまたはLinuxで動作していますか? – identicon
Windowsで走っているなら、 '/ usr/bin/docsplit pdf --output%(dst)s%(src)s'コマンドはPPTをLinuxに変換するとは思えません。 Popenはそのコマンドの処理に問題があり、そのエラーが発生している可能性があります。 – identicon
私は窓で走っています。その場合、回避策はありますか? – grc