我在Redhat上使用我的IPython版本时遇到此错误。
$ ipython --version
Traceback (most recent call last):
File "/usr/bin/ipython", line 7, in <module>
from IPython import start_ipython
File "/usr/lib/python2.7/site-packages/IPython/__init__.py", line 48, in module
from .core.application import Application
File "/usr/lib/python2.7/site-packages/IPython/core/application.py", line 24, in <module>
from IPython.core import release, crashhandler
File "/usr/lib/python2.7/site-packages/IPython/core/crashhandler.py", line 28, in module
from IPython.core import ultratb
File "/usr/lib/python2.7/site-packages/IPython/core/ultratb.py", line 121, in module
from IPython.utils.terminal import get_terminal_size
File "/usr/lib/python2.7/site-packages/IPython/utils/terminal.py", line 27, in module
import backports.shutil_get_terminal_size
**ImportError: No module named shutil_get_terminal_size**
你能帮我解决一下吗?
答案 0 :(得分:9)
根据this question,请尝试:
conda config --add channels conda-forge
conda install backports.shutil_get_terminal_size
答案 1 :(得分:3)
我和你的问题一样。我通过使用pip install -U ipython
来更新IPython来解决它并且它起作用。希望它有所帮助!
答案 2 :(得分:2)
如果您不想使用conda,请尝试以下操作。
pip install https://github.com/chrippa/backports.shutil_get_terminal_size/archive/159e269450dbf37c3a837f6ea7e628d59acbb96a.zip
答案 3 :(得分:0)
我关注这篇文章 IPython console can't locate "backports.shutil_get_terminal_size" and won't load
更改/usr/lib/python2.7/site-packages/IPython/utils/terminal.py并且它适用于我
答案 4 :(得分:0)
没有卸载/重新安装的东西对我有用。 @ternus在上面的评论中提出了最终对我有用的东西:打开(在linux上)/usr/local/lib/python2.7/dist-packages/IPython/utils/terminal.py并更改行
从backports.shutil_get_terminal_size导入get_terminal_size为_get_terminal_size 到
参考:https://github.com/ipython/ipython/issues/9656 作者:https://github.com/ihincks
答案 5 :(得分:0)
对我来说这有效(在 Debian 上):
apt-get install python-ipython