2012-03-14 1 views
0

passthru()를 사용하여 파이썬 스크립트를 호출 할 때 오류가 발생했습니다. 하위 프로세스 및 파이프)를 PHP로 대체합니다.passthru() + 서브 프로세스의 파이프 = 트레이스 백 (가장 최근 호출 마지막) : stdout = subprocess.PIPE의 (...)

Traceback (most recent call last): File "…/Desktop/h.py", line 11, in stdout=subprocess.PIPE) #set up the convert command and direct the output to a pipe File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/subprocess.py", line 593, in init errread, errwrite) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/subprocess.py", line 1079, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory

PHP의의 경유 :

<?php 
passthru("/usr/bin/python2.5 /Users/Nagar/Desktop/h.py $argument1 $argument2 1 2>&1"); 
?> 
오류의 원인이

내 파이썬 라인 :

p1 = subprocess.Popen(['convert', fileIn, 'pnm:-'], stdout=subprocess.PIPE) #set up the convert command and direct the output to a pipe 

사용하는 방법을 표준 출력 = subprocess.PIPE 여기

오류입니다 제대로 하위 프로세스에 있습니까?

답장을 보내주십시오.

답변

0

PATH에 "convert"명령이 포함 된 디렉토리가없는 것 같습니다. 교체하십시오 :

p1 = subprocess.Popen(['convert', fileIn, 'pnm:-'], stdout=subprocess.PIPE) 

로 :

p1 = subprocess.Popen(['/full/path/to/convert', fileIn, 'pnm:-'], stdout=subprocess.PIPE) 

여기서 "는/usr/빈/변환"와 같은 "/ 전체/경로// 변환"수 있습니다 뭔가.

1

는 쉘을 실행해야하기 때문에, 그래서 당신은 쉘 인수 True로 설정해야합니다

p1 = subprocess.Popen(['convert', fileIn, 'pnm:-'], stdout=subprocess.PIPE, shell=True)convert command and direct the output to a pipe