我使用Pycharm 2016.1的CentOS7,我测试" Show command line afterwards",我得到了这个问题:
AttributeError: 'PyDevTerminalInteractiveShell' object has no attribute 'has_readline'
Run Code Online (Sandbox Code Playgroud)
/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'
Run Code Online (Sandbox Code Playgroud)
dan*_*van 49
这个PyCharm问题的发生是因为iPythonapi与iPython版本5 的更改.直到Jetbrains修复此问题,恢复到早期版本iPython(版本4)才能解决这个问题.正如@chenfei发现的那样,这可以通过pip以下方式完成:
$ pip uninstall ipython
$ pip install ipython==4.2.0
Run Code Online (Sandbox Code Playgroud)
编辑
如果你不能等那么久,Jetbrains已经发布了补丁
https://youtrack.jetbrains.com/issue/PY-20013#comment=27-1512407
最终编辑
这个问题已在PyCharm 2016.2中修复
che*_*fei 11
我通过安装ipython版本4.2解决了我的问题:
pip uninstall ipython
pip install ipython==4.2.0
Run Code Online (Sandbox Code Playgroud)
我设法解决这个问题没有降级的方式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/
Run Code Online (Sandbox Code Playgroud)
Pycharm将提示您导入该文件夹上的文件,接受.
3 - 单击VCS并选择Apply Patch
4 - 选择您在步骤1中下载的文件.
5 - Apply Patch窗口将打开,单击OK
6 - 重启PyCharm
Python控制台现在应该在里面工作 PyCharm
PS:您可以删除在步骤2中创建的项目文件夹(.idea)