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

2024-10-16 20:48:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我不知道为什么,但是自从Python3.8发布以来,我不能运行pycharm控制台,它总是处于“正在连接”状态。在

我对Python3.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)

照片:

The screen shot

pycharm规格:pycharm专业版2019.1.3


Tags: inpyparserpartylinefilesprogramhelpers
1条回答
网友
1楼 · 发布于 2024-10-16 20:48:55

它在PyCharm(社区)2019.3中效果良好。在

PyCharm发布了[PyPI]: thriftpy(对于当前版本,它是一个修改过的v0.3.8),因为它需要它来实现不同的功能(包括Python控制台)。在

python3.8附带了一组更改(一个例子是[Python]: PEP 570 Python Positional-Only Parameters),需要对许多现有的(3rd-party)包进行更改才能使它们工作(对于其中一些包,仍然存在WiP)。在

显然,ThriftPy是需要更改的包之一。然而,它自2016年起就没有被维护过,所以JetBrains保留了(一个拷贝/分叉?)在他们的存储库中。在

总之,您面临的问题已由[GitHub]: JetBrains/intellij-community - PY-36069 Python console support for Python 3.8修复。
不幸的是,我在JetBrains.YouTrack上找不到该问题,因此我没有关于它的任何其他信息(例如,当它被修复时,等等)。在

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

一个解决方法(如果不能升级)是将补丁(在commitURL中)应用到您的(本地)_兼容文件。查看[SO]: Run / Debug a Django application's UnitTests from the mouse right click context menu in PyCharm Community Edition? (@CristiFati's answer)补丁utrunner部分),了解如何应用补丁程序(onWin)。
小提示:将反向补丁应用于本地文件,使问题变得可见。在

相关问题 更多 >