You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ImportError: No module named shutil_get_terminal_size #9815
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
from IPython import start_ipython
File "/usr/local/lib/python2.7/dist-packages/IPython/init.py", line 48, in
from .core.application import Application
File "/usr/local/lib/python2.7/dist-packages/IPython/core/application.py", line 25, in
from IPython.core import release, crashhandler
File "/usr/local/lib/python2.7/dist-packages/IPython/core/crashhandler.py", line 28, in
from IPython.core import ultratb
File "/usr/local/lib/python2.7/dist-packages/IPython/core/ultratb.py", line 128, in
from IPython.utils.terminal import get_terminal_size
File "/usr/local/lib/python2.7/dist-packages/IPython/utils/terminal.py", line 22, in
from backports.shutil_get_terminal_size import get_terminal_size as _get_terminal_size
ImportError: No module named shutil_get_terminal_size
jiangyuping@Lenovo:~/ipython$ pip install ipython
Requirement already satisfied (use --upgrade to upgrade): ipython in /usr/local/lib/python2.7/dist-packages
then, ipython, it appears
jiangyuping@Lenovo:~/ipython$ ipython
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 4, in
from IPython import start_ipython
File "/home/jiangyuping/ipython/IPython/init.py", line 48, in
from .core.application import Application
File "/home/jiangyuping/ipython/IPython/core/application.py", line 25, in
from IPython.core import release, crashhandler
File "/home/jiangyuping/ipython/IPython/core/crashhandler.py", line 28, in
from IPython.core import ultratb
File "/home/jiangyuping/ipython/IPython/core/ultratb.py", line 128, in
from IPython.utils.terminal import get_terminal_size
File "/home/jiangyuping/ipython/IPython/utils/terminal.py", line 22, in
from backports.shutil_get_terminal_size import get_terminal_size as _get_terminal_size
ImportError: No module named shutil_get_terminal_size
I don't remember exactly, but I do remember it's pretty easy. My steps:
Google search for that file with the extension .whl and
google search How To Install A Whl File
hm. ok that looks snarky or something. I'm being sincere and trying to help. But that's literally what I did. Pretty sure the file came from pypi. I'm guessing a whl file could possibly install Anything, so I made sure it came from a reputable source.
I'm guessing the command was: pip install --upgrade backports.shutil_get_terminal_size.whl
# start by making sure pip, setuptools are up to date:
pip install --upgrade setuptools pip
# 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
Reacted by Taras Matsyk, Shreyas Patil, Tony Schroeder, Yonti Levin, Wang Yu, ifermion, howz-chen, Wesley Pennington, Evan Lu, Yann Dupis and 18 more
^ Minrk has better advice.
Minrk, you wrote "if pip thinks you already have it but don't seem to". So, it's possible that the file was scheduled in the initial python install but then missed? Thus it's listed as present but really isn't?
pde@damoclid:~$ ipython
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line 48, in <module>
from .core.application import Application
File "/usr/lib/python2.7/dist-packages/IPython/core/application.py", line 25, in <module>
from IPython.core import release, crashhandler
File "/usr/lib/python2.7/dist-packages/IPython/core/crashhandler.py", line 28, in <module>
from IPython.core import ultratb
File "/usr/lib/python2.7/dist-packages/IPython/core/ultratb.py", line 128, in <module>
from IPython.utils.terminal import get_terminal_size
File "/usr/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
pde@damoclid:~$ python
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import backports.shutil_get_terminal_size
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named shutil_get_terminal_size
>>> import sys
>>> print [p for p in sys.path if os.path.exists(p + "/backports")]
['/usr/lib/python2.7/dist-packages']
>>> import backports
>>> backports.__path__
['/usr/local/lib/python2.7/dist-packages/backports']
>>> os.path.exists("/usr/local/lib/python2.7/dist-packages/backports")
False
>>> dir(backports)
['__doc__', '__name__', '__path__']
>>>
pde@damoclid:~$ cd /usr/local/bin/
pde@damoclid:/usr/local/bin$ cd ..
pde@damoclid:/usr/local$ sudo find . -iname \*backports\*
pde@damoclid:/usr/local$
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 of backports in /usr/local/lib. My sys.path is:
@Carreau fwiw it feels like there might be a pip or python bug here, or I did something foolish, or perhaps both. Will run it past some more knowledgeable pip people.
Another case where it's finding a backports package that isn't really there. A few people have reported something like that, but I can't figure out where it comes from either. Could you have a go at running this script? And look around for .pkg and .pth files, which might be affecting it.
@Carreau on my system, the problem turned out to be the presence of the configparser module:
pde@damoclid:~/aip$ sudo grep backport `locate *.pth`
/usr/local/lib/python2.7/dist-packages/configparser-3.5.0-nspkg.pth:import sys, types, os;p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('backports',));ie = os.path.exists(os.path.join(p,'__init__.py'));m = not ie and sys.modules.setdefault('backports', types.ModuleType('backports'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
pde@damoclid:~/aip$ pip freeze | grep configp
configparser==3.3.0.post2
pde@damoclid:~/aip$ cd /usr/local/lib/
pde@damoclid:/usr/local/lib$ find . -iname *configp*
./python2.7/dist-packages/configparser-3.5.0.dist-info
./python2.7/dist-packages/future/moves/configparser.py
./python2.7/dist-packages/future/moves/configparser.pyc
./python2.7/dist-packages/configparser.py
./python2.7/dist-packages/configparser-3.5.0-nspkg.pth
./python2.7/dist-packages/configparser.pyc
pde@damoclid:/usr/local/lib$ sudo pip uninstall configparser
Not uninstalling configparser at /usr/lib/python2.7/dist-packages, outside environment /usr
pde@damoclid:/usr/local/lib$ sudo rm -rf `find . -iname *configp*`
pde@damoclid:/usr/local/lib$ ipython
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
Type "copyright", "credits" or "license" for more information.
IPython 5.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]:
Do you really want to exit ([y]/n)? y
Activity
takluyver commentedon Jul 28, 2016
You have a newer copy of IPython installed outside apt, and it requires the package backports.shutil_get_terminal_size. Use
pipto install that.applar commentedon Jul 28, 2016
@takluyver After
pip install ipython, it appearsjiangyuping@Lenovo:~/ipython$ pip install ipython
Requirement already satisfied (use --upgrade to upgrade): ipython in /usr/local/lib/python2.7/dist-packages
then,
ipython, it appearsjiangyuping@Lenovo:~/ipython$ ipython
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 4, in
from IPython import start_ipython
File "/home/jiangyuping/ipython/IPython/init.py", line 48, in
from .core.application import Application
File "/home/jiangyuping/ipython/IPython/core/application.py", line 25, in
from IPython.core import release, crashhandler
File "/home/jiangyuping/ipython/IPython/core/crashhandler.py", line 28, in
from IPython.core import ultratb
File "/home/jiangyuping/ipython/IPython/core/ultratb.py", line 128, in
from IPython.utils.terminal import get_terminal_size
File "/home/jiangyuping/ipython/IPython/utils/terminal.py", line 22, in
from backports.shutil_get_terminal_size import get_terminal_size as _get_terminal_size
ImportError: No module named shutil_get_terminal_size
takluyver commentedon Jul 28, 2016
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:
applar commentedon Jul 28, 2016
Thank you, installed successfully.
AllanDaemon commentedon Sep 21, 2016
I tried a lot of things. The last one that solved was updating
setuptools. I also updated pip and reinstalled ipython, etc.jnault commentedon Oct 16, 2016
Thanks! This did Not work for me. But it gave me an idea... I did a pip install --upgraded with a whl file of the backports.shutil_get_terminal_size
Prior to that simply doing a pip install resulted in "requirement already satisfied" etc.
Now I can run Turi's GraphLab Create :)
oschow commentedon Oct 28, 2016
@jnault I'm having the same problem because I tried to install Turi's GraphLab Create. What exact commands did you use?
jnault commentedon Oct 28, 2016
I don't remember exactly, but I do remember it's pretty easy. My steps:
hm. ok that looks snarky or something. I'm being sincere and trying to help. But that's literally what I did. Pretty sure the file came from pypi. I'm guessing a whl file could possibly install Anything, so I made sure it came from a reputable source.
I'm guessing the command was: pip install --upgrade backports.shutil_get_terminal_size.whl
minrk commentedon Oct 28, 2016
@oschow this should work in general:
jnault commentedon Oct 28, 2016
^ Minrk has better advice.
Minrk, you wrote "if pip thinks you already have it but don't seem to". So, it's possible that the file was scheduled in the initial python install but then missed? Thus it's listed as present but really isn't?
fredtony commentedon Nov 23, 2016
I had the same problem when trying to install Graphlab Create. minrk's solution fixed it for me as well.
ifermion commentedon Dec 7, 2016
@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
bevice commentedon Jan 7, 2017
remove
<path-to>/Python/2.7/site-packages/backports/__init__.*59 remaining items
Vic020 commentedon Apr 26, 2017
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.
pde commentedon May 16, 2017
I have a very odd version of this bug:
pde commentedon May 16, 2017
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 ofbackportsin /usr/local/lib. Mysys.pathis:['', '/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']Carreau commentedon May 16, 2017
I'm going to reopen and tag as 5.4 I think we should vendor
shutil_get_terminal_sizeto be safe.pde commentedon May 16, 2017
@Carreau fwiw it feels like there might be a pip or python bug here, or I did something foolish, or perhaps both. Will run it past some more knowledgeable pip people.
takluyver commentedon May 16, 2017
Another case where it's finding a
backportspackage that isn't really there. A few people have reported something like that, but I can't figure out where it comes from either. Could you have a go at running this script? And look around for.pkgand.pthfiles, which might be affecting it.pde commentedon May 16, 2017
@Carreau on my system, the problem turned out to be the presence of the
configparsermodule:Thanks to @erikrose for help debugging this.
pde commentedon May 16, 2017
https://bitbucket.org/ambv/configparser/issues/17/importerror-when-used-with-other-backports
Vendor shutil.get_terminal_size.
Vendor shutil.get_terminal_size.
Carreau commentedon May 29, 2017
Closing as #10587 vendor this things and IPython 5.4 should be released soon