r/IPython • u/kakibb • Jun 27 '16
What is wrong?
on terminal, it works good, but on ipython notebook it doesn't work.
sumoProcess = subprocess.Popen([sumoBinary, "-c", "data/cross.sumocfg", "--tripinfo-output","tripinfo.xml", "--remote-port", str(PORT)], stdout=sys.stdout, stderr=sys.stderr)
UnsupportedOperationTraceback (most recent call last)
<ipython-input-15-80cdeae4d531> in <module>()
----> 1 sumoProcess = subprocess.Popen([sumoBinary, "-c", "data/cross.sumocfg", "--tripinfo-output","tripinfo.xml", "--remote-port", str(PORT)], stdout=sys.stdout, stderr=sys.stderr)
/usr/lib/python2.7/subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
700 (p2cread, p2cwrite,
701 c2pread, c2pwrite,
--> 702 errread, errwrite), to_close = self._get_handles(stdin, stdout, stderr)
703
704 try:
/usr/lib/python2.7/subprocess.pyc in _get_handles(self, stdin, stdout, stderr)
1126 else:
1127 # Assuming file-like object
-> 1128 c2pwrite = stdout.fileno()
1129
1130 if stderr is None:
/usr/local/lib/python2.7/dist-packages/ipykernel/iostream.pyc in fileno(self)
304
305 def fileno(self):
--> 306 raise UnsupportedOperation("IOStream has no fileno.")
307
308 def write(self, string):
UnsupportedOperation: IOStream has no fileno.
Python 2.7.6
0
Upvotes
0
2
u/hharison Jun 27 '16
The notebook messes with sys.stdout and sys.stderr. The solution depends on what you're trying to accomplish. Do you want the output to go into the notebook output area, or into the terminal where the notebook was launched from?