pycharm 无法使用 python3.8 连接到控制台

moh*_*80s 16 python console pycharm python-3.8

我不知道为什么;但是自从python 3.8发布之后;我无法运行 pycharm 控制台,它始终处于“正在连接”状态。

我对 python 3.7 没有问题;因为控制台会立即打开。

在这里你可以看到我已经尝试了几次运行控制台,但我知道,即使我等了一天;它不连接到控制台;但是当我将解释器从 python3.8 更改为 python3.7 时,我打开的新控制台都在一秒钟内设置好了。

错误:

C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\_pydevd_bundle\pydevd_resolver.py:138: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if found.get(name) is not 1:
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\pydevconsole.py", line 33, in <module>
    from _pydev_bundle.pydev_console_utils import BaseInterpreterInterface
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\_pydev_bundle\pydev_console_utils.py", line 11, in <module>
    from _pydevd_bundle import pydevd_thrift
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\_pydevd_bundle\pydevd_thrift.py", line 17, in <module>
    from pydev_console.protocol import DebugValue, GetArrayResponse, ArrayData, ArrayHeaders, ColHeader, RowHeader, \
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\pydev_console\protocol.py", line 6, in <module>
    _console_thrift = _shaded_thriftpy.load(os.path.join(os.path.dirname(os.path.realpath(__file__)), "console.thrift"),
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_thriftpy\parser\__init__.py", line 29, in load
    thrift = parse(path, module_name, include_dirs=include_dirs,
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_thriftpy\parser\parser.py", line 502, in parse
    parser.parse(data)
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_ply\yacc.py", line 331, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_ply\yacc.py", line 1106, in parseopt_notrack
    p.callable(pslice)
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_thriftpy\parser\parser.py", line 212, in p_struct
    val = _fill_in_struct(p[1], p[3])
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_thriftpy\parser\parser.py", line 765, in _fill_in_struct
    gen_init(cls, thrift_spec, default_spec)
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_thriftpy\thrift.py", line 103, in gen_init
    cls.__init__ = init_func_generator(default_spec)
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_thriftpy\_compat.py", line 102, in init_func_generator
    new_code = types.CodeType(len(varnames),
TypeError: an integer is required (got type bytes)

Run Code Online (Sandbox Code Playgroud)

照片:

屏幕截图

pycharm 规格:pycharm 专业版 2019.1.3

Cri*_*ati 13

它在PyCharm (Community) 2019.3上运行良好。

PyCharm提供[PyPI]: thriftpy(对于当前版本,它是经过修改的 v0.3.8),因为它需要它用于不同的功能(包括Python 控制台)。

Python的3.8想出了一组修改(一个例子是[巨蟒]:PEP 570 - Python的阵地,只有参数)需要在许多现有的(3变动为了工作三方)包它们(一些他们,还有在制品)。

显然,ThriftPy是需要更改的软件包之一。然而,它自 2016 年以来就没有得到维护,因此JetBrains将(副本/分叉?)保存在他们的存储库中。

无论如何,您面临的问题已由[GitHub] 解决:JetBrains/intellij-community - PY-36069 Python 控制台支持 Python 3.8
不幸的是,我在JetBrains.YouTrack上找不到这个问题,所以我没有关于它的任何其他信息(比如它何时被修复等等)。

我可以告诉你的(开头也提到过),它在PyCharm (Community) 2019.3 中已经修复(有效),所以如果你升级它,你应该不再有这个问题。

解决方法(如果升级不是一种选择)是将补丁(在提交URL 中)应用到您的(本地)_compat.py文件。检查[SO]:从 PyCharm 社区版中的鼠标右键单击上下文菜单运行/调试 Django 应用程序的单元测试?(@CristiFati 的回答)Patching utrunner部分)了解如何应用补丁(在Win 上)。
小提一下:将反向补丁应用到我的本地文件,使问题可见。