'PyDevTerminalInteractiveShell'对象没有属性'has_readline'

时间:2016-07-13 01:26:12

标签: python pycharm

我在Pycharm上使用2016.1 CentOS7,我正在测试“Show command line afterwards”,我遇到了这个问题:

AttributeError: 'PyDevTerminalInteractiveShell' object has no attribute 'has_readline'
/usr/bin/python3.4 /usr/local/pycharm/helpers/pydev/pydev_run_in_console.py 37196 52554 /root/PycharmProjects/mytf/mytest/test5.py
Traceback (most recent call last):
File "/usr/local/pycharm/helpers/pydev/pydev_run_in_console.py", line 63, in <module>
  interpreter = InterpreterInterface(host, int(client_port), threading.currentThread())
File "/usr/local/pycharm/helpers/pydev/_pydev_bundle/pydev_ipython_console.py", line 26, in __init__
  self.interpreter = get_pydev_frontend(host, client_port, show_banner=show_banner)
File "/usr/local/pycharm/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py", line 473, in get_pydev_frontend
  _PyDevFrontEndContainer._instance = _PyDevFrontEnd(show_banner=show_banner)
File "/usr/local/pycharm/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py", line 303, in __init__
  self.ipython = PyDevTerminalInteractiveShell.instance()
File "/usr/lib/python3.4/site-packages/traitlets/config/configurable.py", line 412, in instance
  inst = cls(*args, **kwargs)
File "/usr/lib/python3.4/site-packages/IPython/terminal/interactiveshell.py", line 359, in __init__
  super(TerminalInteractiveShell, self).__init__(*args, **kwargs)
File "/usr/lib/python3.4/site-packages/IPython/core/interactiveshell.py", line 487, in __init__
  self.init_completer()
File "/usr/local/pycharm/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py", line 222, in init_completer
  self.Completer = self._new_completer_200()
File "/usr/local/pycharm/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py", line 194, in _new_completer_200
  use_readline=self.has_readline,
AttributeError: 'PyDevTerminalInteractiveShell' object has no attribute 'has_readline'

4 个答案:

答案 0 :(得分:49)

由于iPython api与iPython版本5的更改,发生此PyCharm问题。在Jetbrains修复此问题之前,还原到早期版本的iPython(版本4)将更正此问题。正如@chenfei发现的那样,这可以通过pip

来完成
$ pip uninstall ipython
$ pip install ipython==4.2.0

修改

如果你不能等那么久,Jetbrains已经发布了补丁

https://youtrack.jetbrains.com/issue/PY-20013#comment=27-1512407

最终修改

此问题已在PyCharm 2016.2中修复。

答案 1 :(得分:11)

我通过安装ipython版本4.2解决了我的问题:

pip uninstall ipython
pip install ipython==4.2.0

答案 2 :(得分:6)

我设法解决此问题而不降级iPython 的方式是:

1 - 下载以下补丁:

https://youtrack.jetbrains.com/_persistent/pycharm_ipython5_fix.patch?file=74-327779&c=true

2 - 在PyCharm内,创建一个位于以下位置的新项目:

<PyCharm installation folder>/helpers/pydev/_pydev_bundle/

Pycharm会提示您导入该文件夹上的文件接受

3 - 点击 VCS 并选择 Apply Patch

4 - 选择您在第1步上下载的文件。

5 - Apply Patch 窗口将打开,单击确定

6 - 重新启动PyCharm

Python控制台现在应该在PyCharm

内部工作

PS:你可以删除你在第2步

上创建的项目文件夹(.idea)

答案 3 :(得分:1)