question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot launch Ipython3. OSError: [Errno 9] Bad file descriptor

See original GitHub issue
Python 3.5.2+ (default, Sep 22 2016, 12:18:14) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.0.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]:                                                                                                                                               
Traceback (most recent call last):
  File "/usr/local/bin/ipython3", line 11, in <module>
    sys.exit(start_ipython())
  File "/usr/local/lib/python3.5/dist-packages/IPython/__init__.py", line 125, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/usr/local/lib/python3.5/dist-packages/IPython/terminal/ipapp.py", line 353, in start
    self.shell.mainloop()
  File "/usr/local/lib/python3.5/dist-packages/IPython/terminal/interactiveshell.py", line 459, in mainloop
    self.interact()
  File "/usr/local/lib/python3.5/dist-packages/IPython/terminal/interactiveshell.py", line 442, in interact
    code = self.prompt_for_code()
  File "/usr/local/lib/python3.5/dist-packages/IPython/terminal/interactiveshell.py", line 355, in prompt_for_code
    pre_run=self.pre_prompt, reset_current_buffer=True)
  File "/usr/local/lib/python3.5/dist-packages/prompt_toolkit/interface.py", line 411, in run
    with self.input.raw_mode():
  File "/usr/local/lib/python3.5/dist-packages/prompt_toolkit/terminal/vt100_input.py", line 473, in __enter__
    os.write(self.fileno, b'\x1b[?1l')
OSError: [Errno 9] Bad file descriptor

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
malthejorgensencommented, Jun 1, 2018

This happened to me on OS X 10.12.6 in a long lived tmux tab. I use fish as my shell. Starting the iPython REPL in any of the other tabs in the same tmux session worked. Reconnecting to the session and trying in the same tab still gave the same error.

In my case I believe, something happened to that particular fish session.

0reactions
refi64commented, May 21, 2020

I actually think this is an IPython bug. Here’s what I’ve found:

In many cases, stdout and stdin both are pointing to the same PTY device, so if they’re open as read-write, writing to stdin is actually writing to stdout, and reading from stdout is actually reading from stdin. You can observe this by running: os.write(0, b'test\n') in Python: it’ll write to the same PTY.

However, according to the posix standard, nothing is mentioned about stdin being writable or stdout being readable. (It does say that stderr must be rw.)

Thus, in this case, I think IPython could get identical behavior by writing to stdout instead. In theory this would differ if stdin were a tty and stdout were a different one, but tbh I’ve never seen that before, and I’m not sure what exactly would be going on there or what type of behavior would even be expected.

Please feel free to correct anything here that seems off, but I thought this would at least be something worth adding to the discussion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OSError: [Errno 9] Bad file descriptor When using pip install
This is after running antivirus scan in my computer. <frozen importlib._bootstrap_external ,line 973, in get_data OSError: [Errno 9] Bad file ...
Read more >
[Errno 9] Bad file descriptor - Google Groups
For some reasons, IOLoop.current().run_sync() starts raising next error: OSError: [Errno 9] Bad file descriptor. Some days ago it worked fine.
Read more >
What can lead to “IOError: [Errno 9] Bad file descriptor” during ...
I'm using os.system(), which is a scientific software including a python script, used to run another scientific program.
Read more >
"OSError: [Errno 9] bad file decriptor". Why this error?
Not any error but “OSError: [Errno 9] bad file descriptor”. I don't know why I have been getting this error. ... I'm actually...
Read more >
[Errno 9] Bad File Descriptor Python Solved
In Python, file descriptors are integers(positive) that identify the kernel's open files kept in a table of files. They are generally non- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found