2016-06-09 227 views
4

我在Redhat上使用我的IPython版本時出現此錯誤。ImportError:沒有名爲shutil_get_terminal_size的模塊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** 

你能幫我解決嗎?

+2

類似quesiton並回答在這裏:http://stackoverflow.com/questions/372 32446/ipython-console-cant-locate-backports-shutil-get-terminal-size-and-wont-load – mhrtsh

+0

我嘗試卸載並重新安裝,但仍然出現同樣的問題 – Majid

回答

1

我得到了同樣的問題你。我使用pip install -U ipython來解決它,以更新IPython及其工作。希望能幫助到你!

+0

對於我來說,我需要升級pip並專門setuptools用'pip install --upgrade setuptools pip'並重新安裝(刪除並重新安裝)ipython。 –

8

this question,嘗試:

conda config --add channels conda-forge 
conda install backports.shutil_get_terminal_size 
1

如果你不這樣做想要使用conda,請在下面嘗試。 pip install https://github.com/chrippa/backports.shutil_get_terminal_size/archive/159e269450dbf37c3a837f6ea7e628d59acbb96a.zip

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 到

從shutil_backports進口get_terminal_size作爲_get_terminal_size

參考:https://github.com/ipython/ipython/issues/9656 作者:https://github.com/ihincks

相關問題