ipython: ImportError: No module named shutil_get_terminal_size
Update from @carreau : Reopening, tagging 5.4 we should vendor shutil_get_terminal_size.
After installing ipython sudo apt-get install ipython-notebook
, ipython
it appears a error, as follows:
jiangyuping@Lenovo:~$ ipython Traceback (most recent call last): File “/usr/local/bin/ipython”, line 4, in <module> from IPython import start_ipython File “/usr/local/lib/python2.7/dist-packages/IPython/init.py”, line 48, in <module> from .core.application import Application File “/usr/local/lib/python2.7/dist-packages/IPython/core/application.py”, line 25, in <module> from IPython.core import release, crashhandler File “/usr/local/lib/python2.7/dist-packages/IPython/core/crashhandler.py”, line 28, in <module> from IPython.core import ultratb File “/usr/local/lib/python2.7/dist-packages/IPython/core/ultratb.py”, line 128, in <module> from IPython.utils.terminal import get_terminal_size File “/usr/local/lib/python2.7/dist-packages/IPython/utils/terminal.py”, line 22, in <module> from backports.shutil_get_terminal_size import get_terminal_size as _get_terminal_size ImportError: No module named shutil_get_terminal_size
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 81 (34 by maintainers)
Commits related to this issue
- Vendor shutil.get_terminal_size. Use the vendored version only if import error. That should fix import error for many users. Closes #9815. This is only against the 5.x branch as this is in the stdl... — committed to Carreau/ipython by Carreau 7 years ago
- Vendor shutil.get_terminal_size. Use the vendored version only if import error. That should fix import error for many users. Closes #9815. This is only against the 5.x branch as this is in the stdl... — committed to Carreau/ipython by Carreau 7 years ago
@oschow this should work in general:
@minrk had the working solution for me, just an uninstall followed by an install worked for me. Here is what I did.
uninstall if pip thinks you already have it but don’t seem to:
pip uninstall backports.shutil_get_terminal_size
install it again with out definitely-up-to-date pip:
pip install --upgrade backports.shutil_get_terminal_size
I really can’t tell why python isn’t finding the native OS packaged
backports
/backports.shutil_get_terminal_size
, or why it is finding a ghostly version ofbackports
in /usr/local/lib. Mysys.path
is:['', '/usr/lib/python2.7/dist-packages', '/usr/local/lib/python2.7/dist-packages/ropevim-0.7.0-py2.7.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/home/pde/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/wx-3.0-gtk2']
Hello guys,
if you guys have try to fix this with
but it didn’t work.
The best way is that examine your sys path
check each path if there is backports package before the correct path of ipython model and delete it directly.
I too got the same problem…I installed jupyter recently and when i tried to open a ipython notebook file it says the kernel is dead with an import error for backports.shutil_get_terminal_size. Finally, I solved this problem after upgrading pip, re-installing jupyter and backports.shutil-get-terminal-size several times…and finally running this command : python2 -m ipykernel install --user. That gave life to my kernel. Ref : http://askubuntu.com/questions/847263/install-jupyter-for-python-2-7-in-ubuntu-14-04
OK, glad you got it working. The output from the script now shows things as they’re supposed to be; hopefully the script might be useful if someone has this problem in future.
Alright!!!1
This is what I did to somehow make it work. Uninstalled ipython and jupyter and backports.shutil_get_window_size with both conda and pip:
I made sure there is nothing left of any package. Then I reinstalled only ipython with conda:
And now it works!!! Thanks for your generous time @takluyver !
I think this means you have another
backports.<something>
package installed somewhere that has messed up the namespace package machinery. You’ll probably need to find that and uninstall it. Trypip list
to see all installed packages.remove
<path-to>/Python/2.7/site-packages/backports/__init__.*
I meant:
However, if it’s not bringing that as a dependency of IPython, that probably means you have an old version of pip. To upgrade it: