关于python 3.x:更新后Pycharm控制台无法连接

Pycharm console cannot connect after update

我刚刚更新了Pycharm,除了提供以下错误的"Python控制台"之外,一切正常:

"/ Applications / PyCharm CE.app/Contents/helpers/pydev/pydevconsole.py"52830 52831

Traceback(最近一次调用最后一次):

文件"/ Applications / PyCharm CE.app/Contents/helpers/pydev/pydevconsole.py",第526行,
pydevconsole.start_server(host,int(port),int(client_port),client_host)

文件"/ Applications / PyCharm CE.app/Contents/helpers/pydev/pydevconsole.py",第347行,在start_server中
interpreter = InterpreterInterface(client_host,client_port,threading.currentThread())

文件"/ Applications / PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_ipython_console.py",第24行,在init中
self.interpreter = get_pydev_frontend(host,client_port)

在get_pydev_frontend中输入文件"/ Applications / PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py",第461行
_PyDevFrontEndContainer._instance = _PyDevFrontEnd()

文件"/ Applications / PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py",第310行,在init中
self.ipython = PyDevTerminalInteractiveShell.instance()

文件"/Users/kiarash/anaconda/lib/python3.6/site-packages/traitlets/config/configurable.py",第412行,在实例中
inst = cls(* args,** kwargs)

初始化文件"/Users/kiarash/anaconda/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py",第430行
super(TerminalInteractiveShell,self).init(* args,** kwargs)

初始化文件"/Users/kiarash/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py",第516行
self.init_completer()

在init_completer中输入文件"/ Applications / PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py",第234行
self.Completer = self._new_completer_500()

在_new_completer_500中输入文件"/ Applications / PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py",第196行
父=自

文件"/ Applications / PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py",第87行,在init中
self.matchers.remove(self.python_matches)

ValueError:list.remove(x):x不在列表中

进程以退出代码1结束


已经在GitHub上提交了一个补丁(https://github.com/JetBrains/intellij-community/commit/d9f32f650b5a1f4e7a9646011da415d27e18a210)

您也可以将自己的补丁应用于文件路径:

1
<PyCharm Root>/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py

修改:

1
2
3
4
5
6
7
8
9
10
11
     class PyDevIPCompleter(IPCompleter):

     def __init__(self, *args, **kwargs):
        """ Create a Completer that reuses the advanced completion support of PyDev
             in addition to the completion support provided by IPython"""
         IPCompleter.__init__(self, *args, **kwargs)
         # Use PyDev for python matches, see getCompletions below
-        self.matchers.remove(self.python_matches)
+        if self.python_matches in self.matchers:
+            # `self.python_matches` matches attributes or global python names
+            self.matchers.remove(self.python_matches)


我发现ipython就是问题所在
ipython(6.3.0)已更新,但如果你想现在使用pycharm,你应该降级到ipython(6.2.0)