ipython fails to launch
See original GitHub issueI am completely stuck with a persistant error that stops ipython from launching for the past few days. It initially started when I upgraded ipython to 8.0, but now occurs for previous ipython versions as well.
Background: I am running python on Windows 10 using the 64-bit build downloaded from https://www.python.org/. I am using pip and running python and ipython from the mobaxterm terminal. I had been able to run ipython for the past couple of years this way without issue.
The error: Unfortunately, after a recent pip package update, ipython now fails to launch and returns the following message:
03/02/2022 21:02.44 /home/mobaxterm ipython
Python 3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.0.1 -- An enhanced Interactive Python. Type '?' for help.
Traceback (most recent call last):
File "C:\Users\Andrew Friedman\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Andrew Friedman\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Andrew Friedman\AppData\Local\Programs\Python\Python39\Scripts\ipython.exe\__main__.py", line 7, in <module>
sys.exit(start_ipython())
File "C:\Users\Andrew Friedman\AppData\Local\Programs\Python\Python39\lib\site-packages\IPython\__init__.py", line 123, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "C:\Users\Andrew Friedman\AppData\Local\Programs\Python\Python39\lib\site-packages\traitlets\config\application.py", line 845, in launch_instance
app.initialize(argv)
File "C:\Users\Andrew Friedman\AppData\Local\Programs\Python\Python39\lib\site-packages\traitlets\config\application.py", line 88, in inner
return method(app, *args, **kwargs)
File "C:\Users\Andrew Friedman\AppData\Local\Programs\Python\Python39\lib\site-packages\IPython\terminal\ipapp.py", line 283, in initialize
self.init_code()
File "C:\Users\Andrew Friedman\AppData\Local\Programs\Python\Python39\lib\site-packages\IPython\core\shellapp.py", line 315, in init_code
sys.stderr.flush()
AttributeError: 'NoneType' object has no attribute 'flush'
The distressing thing is that I’m unable to get back to the previous ipython functionality, so it is now completely unusable. I have removed and reinstalled python and all of my pip packages several times, and removed the .ipython/ directory, but I continue to get the same error. It persists even when I downgrade python or ipython back to earlier versions that used to work fine (7.31 or 7.22).
Many thanks in advance for any suggestions.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:14 (5 by maintainers)
Hello, I was looking at this again and found that running ipython like this:
python -m IPython
works fine. It’s only when using the ipython.exe executable (located inC:\Python310\Scripts\ipython.exe
) from bash thatsys.stderr
is None.So it seems the problem does not come from ipython but the shim .exe files themselves. I did the same check using
pip.exe
andpython -m pip
and surelysys.stderr
was also set toNone
when running the former.I don’t know how these shims get generated, running xxd on them I can see at the end of the file there’s the actual python script they run, for IPython it’s this:
So the .exe somehow clears
sys.stderr
but only when run from windows bash. My new workaround is toalias ipython="python -m IPython"
in my .bashrcI’m going to close this as non-ipython issue. Anyone encountering this problem is invited to try and install ipython with the version of pip that ships with
distlib==0.3.3
. Remember that pip vendors its dependencies, so the version of distlib in yourpip freeze
does not matter.