'PyDevTerminalInteractiveShell' object has

2019-03-22 11:41发布

I am using Pycharm 2016.1 on CentOS7 and I am testing "Show command line afterwards" and I got this Problem:

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条回答
成全新的幸福
2楼-- · 2019-03-22 12:23

The way I managed to solve this problem without downgrading iPython was:

1 - Download the following patch:

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

2 - Inside PyCharm, create a new project located on:

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

Pycharm will prompt you to import the files on that folder, accept.

3 - Click on VCS and choose Apply Patch

4 - Choose the file you've downloaded on step 1.

5 - The Apply Patch window will open, click OK

6 - Restart PyCharm

The Python Console should be now working inside PyCharm


PS: You can delete the project folder (.idea) you've created on Step 2

查看更多
该账号已被封号
3楼-- · 2019-03-22 12:31

I solved my problem via installing ipython version 4.2:

pip uninstall ipython
pip install ipython==4.2.0
查看更多
虎瘦雄心在
5楼-- · 2019-03-22 12:44

This PyCharm issue occurs because of changes the the iPython api with iPython version 5. Until Jetbrains fix this, reverting to an earlier version of iPython (version 4) will correct this. As @chenfei has discovered, this can be done through pip:

$ pip uninstall ipython
$ pip install ipython==4.2.0

Edit

And if you can't wait that long, Jetbrains have released a patch

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

Final Edit

This issue has been fixed in PyCharm 2016.2

查看更多
登录 后发表回答