我正在尝试在 Nipype 上运行一个简单的 matlab 界面,如下所示,但不知何故它卡在了 run() 代码中。我的命令行不再继续。但是,如果我复制 mlab.cmdline (matlab -nodesktop -nosplash -singleCompThread -r "addpath('/somepath');pyscript;exit") 并将其传递到命令行,它会完美运行。
import nipype.interfaces.matlab as matlab
mlab = matlab.MatlabCommand()
mlab.inputs.script = """ 1+2 """
print mlab.cmdline
res = mlab.run()
print res.runtime
这是 ipython 键盘中断:
^C---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)
173 else:
174 filename = fname
--> 175 __builtin__.execfile(filename, *where)
/new_home/intern2012/yasin/example.py in <module>()
6
7 print mlab.cmdline
----> 8 res = mlab.run()
9
10 print res.runtime
/usr/lib/pymodules/python2.7/nipype/interfaces/base.pyc in run(self, **inputs)
944 version=self.version)
945 try:
--> 946 runtime = self._run_interface(runtime)
947 outputs = self.aggregate_outputs(runtime)
948 runtime.endTime = dt.isoformat(dt.utcnow())
/usr/lib/pymodules/python2.7/nipype/interfaces/matlab.pyc in _run_interface(self, runtime)
136 def _run_interface(self,runtime):
137 self.inputs.terminal_output = 'allatonce'
--> 138 runtime = super(MatlabCommand, self)._run_interface(runtime)
139 try:
140 # Matlab can leave the terminal in a barbbled state
/usr/lib/pymodules/python2.7/nipype/interfaces/base.pyc in _run_interface(self, runtime, correct_return_codes)
1378 setattr(runtime, 'dependencies', get_dependencies(executable_name,
1379 runtime.environ))
-> 1380 runtime = run_command(runtime, output=self.inputs.terminal_output)
1381 if runtime.returncode is None or \
1382 runtime.returncode not in correct_return_codes:
/usr/lib/pymodules/python2.7/nipype/interfaces/base.pyc in run_command(runtime, output, timeout)
1150 result['merged'] = [r[1] for r in temp]
1151 if output == 'allatonce':
-> 1152 stdout, stderr = proc.communicate()
1153 result['stdout'] = stdout.split('\n')
1154 result['stderr'] = stderr.split('\n')
/usr/lib/python2.7/subprocess.pyc in communicate(self, input)
752 return (stdout, stderr)
753
--> 754 return self._communicate(input)
755
756
/usr/lib/python2.7/subprocess.pyc in _communicate(self, input)
1310
1311 if _has_poll:
-> 1312 stdout, stderr = self._communicate_with_poll(input)
1313 else:
1314 stdout, stderr = self._communicate_with_select(input)
/usr/lib/python2.7/subprocess.pyc in _communicate_with_poll(self, input)
1364 while fd2file:
1365 try:
-> 1366 ready = poller.poll()
1367 except select.error, e:
1368 if e.args[0] == errno.EINTR:
我已经阅读subprocess
了该站点中的其他问题,但它们都与Popen()
. 就我而言,有问题poller.poll()
。当它到达这条线时它不再处理。