Jupyter / Tornado“ DeprecationWarning:`should_run_async`将来不会自动调用`transform_cell`”

问题描述

我有一个非常简单的iPython笔记本my_nb.ipynb,其中有两个简单的单元格

from mcmc import Tree
a = Tree()
print(a)

该代码曾经运行时没有问题,但最近在Jupyter中运行时已停止运行(当然,mcmc.py中的代码未更改)。当我使用ipython my_nb.ipynb运行此代码时,脚本可以正常运行并且完成而没有错误。但是,当我在Jupyter中打开笔记本电脑时,第一个单元运行正常,但是第二个单元停滞不前,并且永远不会完成,并且控制台显示以下错误(或警告):

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/ipykernel/kernelbase.py",line 268,in dispatch_shell
    yield gen.maybe_future(handler(stream,idents,msg))
  File "/usr/lib/python3.8/site-packages/tornado/gen.py",line 735,in run
    value = future.result()
  File "/usr/lib/python3.8/site-packages/tornado/gen.py",line 742,in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "/usr/lib/python3.8/site-packages/ipykernel/kernelbase.py",line 542,in execute_request
    reply_content = yield gen.maybe_future(
  File "/usr/lib/python3.8/site-packages/tornado/gen.py",line 209,in wrapper
    yielded = next(result)
  File "/usr/lib/python3.8/site-packages/ipykernel/ipkernel.py",line 287,in do_execute
    and should_run_async(code)
  File "/usr/lib/python3.8/site-packages/IPython/core/interactiveshell.py",line 2954,in should_run_async
    warnings.warn(
DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.

也许更令人困惑的是,如果我将所有代码放在笔记本中的单个单元格中,那么整个代码在Jupyter的命令行中都将正确无误地完成。

我已经检查过this similar thread,但我的ipykernel已更新。实际上,我认为所有相关库都是最新版本:

jupyter core     : 4.6.3
jupyter-notebook : 6.1.4
qtconsole        : not installed
ipython          : 7.18.1
ipykernel        : 5.3.4
jupyter client   : 6.1.6
jupyter lab      : 2.2.7
nbconvert        : 5.6.1
ipywidgets       : 7.5.1
nbformat         : 5.0.6
traitlets        : 4.3.3
tornado          : 6.0.4-2
terminado        : 0.8.3-1

任何帮助,将不胜感激!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)