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

我在CentOS7上使用了Pycharm 2016.1,并且正在testing“Show command line after after”,而我得到了这个问题:AttributeError:'PyDevTerminalInteractiveShell'对象没有属性'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' 

这个PyCharm问题的出现是因为用iPython版本5修改了iPython api。在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中解决了

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

 pip uninstall ipython pip install ipython==4.2.0 

我设法解决这个问题, 而不降级iPython是:

1 – 下载以下补丁:

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

2 – 在PyCharm里面,创build一个新的项目位于:

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

Pycharm会提示你导入该文件夹中的文件, 接受

3 – 点击VCS并select应用修补程序

4 – select您在第1步下载的文件。

5应用补丁窗口将打开,点击确定

6 – 重新启动PyCharm

Python控制台现在应该在PyCharm里面工作


PS:您可以删除您在步骤2中创build的项目文件夹(.idea)

这是在Pycharm 2016.2中解决的。 请参阅: https : //intellij-support.jetbrains.com/hc/en-us/community/posts/207207329-ipython-5-not-supported-by-P​​ycharm-s-python-console-