passthru () + 하위 프로세스의 파이프= 추적 (가장 최근 호출 마지막) : (...) stdout= subprocess.pipe에서)

StackOverflow https://stackoverflow.com//questions/9707520

문제

PASSTHRU ()를 사용하여 PHP를 사용하여 파이썬 스크립트 (하위 프로세스 및 파이프 사용)를 호출 할 때 오류가 발생했습니다.

여기에 오류가 있습니다 :

traceback (가장 최근의 호출) : 파일 "... / desktop / h.py", 11 행, stdout= subprocess.pipe) # 변환 명령을 설정하고 출력을 파이프 파일 "/ 시스템 /라이브러리 / 프레임 워크 / Python.Framework / 버전 / 2.5 / lib / python2.5 / subprocess.py ", init errread, errwrite) 파일"/ system / library / frameworks / python.프레임 워크 / 버전 / 2.5 / lib / python2.5 / subprocess.py ", LINE 1079, in _EXECUTE_CHILD IRASE CHILD_EXCEPTION OSERROR : [errno 2] 해당 파일 또는 디렉토리 없음

php passthru :

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

오류가 발생하는 Python 줄 :

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

STDOUT= SUBPROCESS.PIPE를 하위 프로세스에서 올바르게 사용하는 방법은 무엇입니까?

답변을 기다리고 있습니다.

도움이 되었습니까?

해결책

경로가 "변환"명령을 포함하여 디렉토리가없는 것처럼 보입니다.교체 시도 :

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

다음과 같이 :

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

여기서 "/ full / path / to / convert"는 "/ usr / bin / convert"와 같은 것일 수 있습니다.

다른 팁

쉘을 통해 실행되어야하므로 쉘 인수를 true로 설정해야합니다.

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top