【问题标题】:pycharm does not connect to console with python3.8pycharm 无法使用 python3.8 连接到控制台
【发布时间】:2020-04-09 19:15:06
【问题描述】:

我不知道为什么;但是自从 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)

照片:

pycharm规格:pycharm专业版2019.1.3

【问题讨论】:

  • 你配置解释器了吗? jetbrains.com/help/pycharm/configuring-python-interpreter.html 另外,您的路径中是哪个 python(如果您同时安装了两者)?
  • @Swedgin;是的,我做到了,配置和路径已正确提供给 pycharm。
  • @Swedgin,你猜到错误对我们说了什么吗?
  • 抱歉,帮不了你。很久没有使用pycharm了。我能想到的只有这两个问题。

标签: python console pycharm python-3.8


【解决方案1】:

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

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

Python 3.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 上找不到问题,所以我没有任何关于它的额外信息(比如修复的时间等等)。

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

一种解决方法(如果不能选择升级)是将补丁(在提交 URL 中)应用到您的(本地)_compat.py 文件。查看[SO]: Run / Debug a Django application's UnitTests from the mouse right click context menu in PyCharm Community Edition? (@CristiFati's answer)修补utrunner部分)了解如何应用补丁(在Win上)。
小提示:将反向补丁应用到我的本地文件,使问题可见。

【讨论】:

  • 太好了,谢谢!实际上,我认为 Pycharm 可能已经解决了这个问题,所以我在设置赏金之前更新了 Pycharm,但并没有解决问题。显然,更新是从 1.3 到 1.4,即使版本 3 已经可用。如你所说,再次更新解决了问题。
  • @EllaSharakanski,感谢您的赏金,也感谢@CristiFati 的回复。
  • 我也有这个问题Connecting to console,我无法使用答案的解决方案,因为我需要运行 PyCharm 2018.3,因为这是支持 32 位的最后一个版本。我正在使用普通的 Python 解释器。我可以使用菜单中的“运行”来运行 Python 脚本,但是如果我右键单击选定的行并选择“在控制台中执行选择”(或 Alt+Shift+E),则不会执行。我在github.com/JetBrains/intellij-community/commit/… 上添加了一条评论以解决 PyCharm 2018.3 的问题
  • @Lorenz:您可以将更改应用到本地安装,正如我在回答末尾所指示的那样。
  • 我在“C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.7\helpers\third_party\thriftpy_shaded_thriftpy\”中发现了_combat.py。我将它复制到“C:\tmp\”,然后将代码从红色更改为绿色,如您的提交 URL github.com/JetBrains/intellij-community/commit/…。然后我将结尾从 .py 重命名为 .patch。然后我点击了您的链接,Patching utrunner 部分,现在将其应用于“_combat.py”。我使用gnuwin32.sourceforge.net/packages/patch.htm 作为patch.exe 而不是Cygwin 补丁pkg。
猜你喜欢
  • 2020-09-20
  • 1970-01-01
  • 2016-04-15
  • 1970-01-01
  • 2020-04-01
  • 1970-01-01
  • 2020-03-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多