木星 / 龙卷风 "DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future"
Jupyter / Tornado "DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future"
我有一个非常简单的 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 735, in run
value = future.result()
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
如有任何帮助,我们将不胜感激!
你的代码中是否碰巧有 'warnings.filterwarnings("error")' 或类似的行?
我今天刚遇到同样的情况,最终将问题追溯到我的自定义包中使用的这行代码。一旦我在我的代码中注释掉这一行,这个 Jupyter 挂起问题就消失了。
在解决问题的过程中,我看到了这个问题,所以我想我应该把这些信息记录下来,以防其他人可以从中受益。
我有一个非常简单的 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 735, in run
value = future.result()
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
如有任何帮助,我们将不胜感激!
你的代码中是否碰巧有 'warnings.filterwarnings("error")' 或类似的行?
我今天刚遇到同样的情况,最终将问题追溯到我的自定义包中使用的这行代码。一旦我在我的代码中注释掉这一行,这个 Jupyter 挂起问题就消失了。
在解决问题的过程中,我看到了这个问题,所以我想我应该把这些信息记录下来,以防其他人可以从中受益。