subprocess= traceback(最新の呼び出し)のPASSTHRU()+パイプ(最新のコール):( ...)in stdout= subprocess.pipe)

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

質問

PASSTHRU()を使用してPythonスクリプト(サブプロセスとパイプを使用)をPHP。

に電話をかけるとエラーが発生しました。

これがエラーです:

トレースバック(最後の最後の呼び出し):stdout= subprocess.pipeのファイル "... / desktop / h.py"、11行目 ")#corvertコマンドを設定し、出力をパイプファイルにダイレクトする" / system /ライブラリ/ frameworks / python.framework / versions / 2.5 / lib / python2.5 / subprocess.py "、 init errread、errwrite)ファイル" / system / library / frameworks / python。Framework / Versions / 2.5 / lib / python2.5 / subprocess.py "、_execute_child in _execute_child 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をサブプロセスに正しく使用する方法?

あなたの答えを楽しみにしています。

役に立ちましたか?

解決

パスが "convert"コマンドを含むディレクトリがないように見えます。置き換えてみてください:

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

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

ここで、 "/ full / path / 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