分段错误(核心转储),通过产生的方式从NodeJS调用python脚本

我有python脚本通过统计R打印出长列表(通过PypeR)。 这个python脚本工作得很好。

现在我试图通过child_process的spawnfunction从NodeJS运行这个脚本,但是会失败,并显示以下错误:

Traceback (most recent call last): File "pyper_sample.py", line 5, in <module> r=R() File "/home/mehtam/pyper.py", line 582, in __init__ 'prog' : Popen(RCMD, stdin=PIPE, stdout=PIPE, stderr=return_err and _STDOUT or childstderr, startupinfo=info), File "/usr/lib64/python2.6/subprocess.py", line 642, in __init__ errread, errwrite) File "/usr/lib64/python2.6/subprocess.py", line 1234, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory ./temp.sh: line 1: 27500 Segmentation fault (core dumped) python pyper_sample.py o1dn01.tsv cpu_overall child process exited with code : 139 

注意:我的python脚本工作正常。 我已经手动testing过了。

我的Python脚本是完美的。 我已经手动testing过了。

输出清楚地显示OSError: No such file or directoryPopen()调用期间OSError: No such file or directory发生OSError: No such file or directoryexception。

这意味着该程序没有find,例如,

 >>> from subprocess import Popen >>> p = Popen(["ls", "-l"]) # OK >>> total 0 >>> p = Popen(["no-such-program-in-current-path"]) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/subprocess.py", line 679, in __init__ errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory 

另外,将整个命令作为一个string而不是一个列表(默认为shell=False )传递是一个常见的错误:

 >>> p = Popen("ls -l") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/subprocess.py", line 679, in __init__ errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory 

确保:

  • 您的(子)程序可以在当前的$PATHfind
  • 使用列表参数而不是string
  • testing它是否工作,如果你从一个不同的工作目录,不同的用户等手动运行它

注意:您的Popen()调用仅传递Windows的startupinfo 。 一个string命令与多个参数将在Windows上工作失败与Unix上的"No such file or directory"错误。