开发者

Can subprocess.Popen be used when called from py code running under mod_wsgi in Apache2

开发者 https://www.devze.com 2023-01-10 17:23 出处:网络
I\'m using subprocess.Popen and gettin开发者_高级运维g IOErrors when running under mod_wsgi.The following code will work in a python term, or a django runserver, and under mod_python.If you put it und

I'm using subprocess.Popen and gettin开发者_高级运维g IOErrors when running under mod_wsgi. The following code will work in a python term, or a django runserver, and under mod_python. If you put it under mod_wsgi (v2), it fails: (2, 'No such file or directory') I have tried many variations involving using subprocess.PIPE. I have tried to redefine stdout, and to use the httpd directives to turn off mod_wsgi's complains of stdout usage. I recently tried upgrading to version 3.

import subprocess

input_file = 'test.html'

p = subprocess.Popen(['htmldoc','-f', 'output.pdf', '--book', input_file])

p.communicate()

len(open('output.pdf').read())

My test effort is going to be to move back to mod_python, and see if the problem goes away. I'd like to know if anyone else has done this and can shed some light on this problem.


That error message means that Popen can't find htmldoc. Check your $PATH environment variable through os.environ['PATH'] and make sure that htmldoc is installed in one of the paths there.

Alternatively, you can call Popen using an absolute path. For example,

subprocess.Popen(['/usr/bin/htmldoc', ...
0

精彩评论

暂无评论...
验证码 换一张
取 消