问题
I have used a subprocess to convert Docx file to Pdf file in Django. On the server when I run the project with python manage.py runserver command. All things working file but if I run the application with Gunicorn my subprocess not work. Simple "ls" command is also not working. My server has ubuntu 18.04.
I knew that this is related to services which we have to create to run the application on the server but I am not able to find the issue. Thanks in advance.
To generate pdf I have use preview-generator package its working on my local machin but on server this is the error I am having
Command '['libreoffice', '--headless', '--convert-to', 'pdf:writer_pdf_Export', '/root/form_builder/static/temp_folder/d2f851423dd1fecb2ed535c04a603705.pdf.docx', '--outdir', '/root/form_builder/static/temp_folder/', '-env:UserInstallation=file:///tmp/LibreOffice_Conversion_${USER}']' returned non-zero exit status 127.
So to generate pdf I have used custom code which is having subprocess
proc = subprocess.Popen([officepath, '--headless', '--convert-to','pdf:writer_pdf_Export', output_folder, input_file],env=env,stdout=subprocess.PIPE,
stderr=subprocess.PIPE, cwd='/root/form_builder/static/temp_folder/2/', shell=True)
来源:https://stackoverflow.com/questions/59155672/no-command-runs-in-subprocess