Passthru () + tubería en subproceso= Traceback (última llamada más reciente): (...) en stdout= subprocesos.pipe)
-
14-12-2019 - |
Pregunta
Tengo un error cuando estoy usando Passthru () para llamar a un script de Python (usando subproceso y tubería) con PHP.
Aquí está el error:
rastrack (última llamada más reciente): Archivo "... / Desktop / H.PY", Línea 11, en STdout= Subprocess.Pipe) #set Up El comando convertir y dirija la salida a un archivo de tubería "/ SYSTEM /Biblioteca / Marco / Python.Framework / Versiones / 2.5 / lib / python2.5 / subprocess.py ", línea 593, en init errRead, errwite) Archivo" / Sistema / Biblioteca / Frameworks / Python.Marco / Versiones / 2.5 / lib / python2.5 / subprocess.py ", line 1079, en _execute_child rae infant_exception oserror: [errNo 2] No hay dicho archivo o directorio
El PHP PASSTHRU:
<?php
passthru("/usr/bin/python2.5 /Users/Nagar/Desktop/h.py $argument1 $argument2 1 2>&1");
?>
Mi línea de Python que causa el error:
p1 = subprocess.Popen(['convert', fileIn, 'pnm:-'], stdout=subprocess.PIPE) #set up the convert command and direct the output to a pipe
¿Cómo usar stdout= subproceso.pipe correctamente en el subproceso?
Mirando sus respuestas.
Solución
Parece que su camino no tiene el directorio, incluido el comando "Convert".Intente reemplazar:
p1 = subprocess.Popen(['convert', fileIn, 'pnm:-'], stdout=subprocess.PIPE)
con:
p1 = subprocess.Popen(['/full/path/to/convert', fileIn, 'pnm:-'], stdout=subprocess.PIPE)
Dónde "/ Full / Full / Ruta / a / Convertir" podría ser algo así como "/ usr / bin / convertir".
Otros consejos
Es porque debe ser ejecutado a través de una cáscara, por lo que necesita establecer el argumento de Shell a True:
p1 = subprocess.Popen(['convert', fileIn, 'pnm:-'], stdout=subprocess.PIPE, shell=True)convert command and direct the output to a pipe