Skip to content

BUG: Can't run subprocess.Popen(..., stdout=sys.stdout) in IPython window #272

Closed
@larsoner

Description

@larsoner

This fails in Jupyter notebook but passes in plain python and ipython:

import subprocess
import sys
subprocess.Popen(['who'], stdout=sys.stdout)

With output:

---------------------------------------------------------------------------
UnsupportedOperation                      Traceback (most recent call last)
<ipython-input-1-be12742210dd> in <module>()
      1 import subprocess
      2 import sys
----> 3 subprocess.Popen(['who'], stdout=sys.stdout)

~/miniconda3/envs/mne/lib/python3.6/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
    663         (p2cread, p2cwrite,
    664          c2pread, c2pwrite,
--> 665          errread, errwrite) = self._get_handles(stdin, stdout, stderr)
    666 
    667         # We wrap OS handles *before* launching the child, otherwise a

~/miniconda3/envs/mne/lib/python3.6/subprocess.py in _get_handles(self, stdin, stdout, stderr)
   1174             else:
   1175                 # Assuming file-like object
-> 1176                 c2pwrite = stdout.fileno()
   1177 
   1178             if stderr is None:

UnsupportedOperation: fileno

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions