来自Jupyter的弃用警告:“`should_run_async`将来不会自动调用`transform_cell`”

问题描述

当我导入一个软件包时,我收到以下弃用消息。我找不到有关它的任何文档。我知道我可以抑制警告,但我想知道发生了什么。

import pandas as pd

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ipykernel/ipkernel.py:287: 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.
  and should_run_async(code)

安装:Python 3.8.5,jupyter-client 6.1.6,jupyter-core 4.6.3,jupyterlab 2.2.4, 在Mac OS上的jupyterlab-server 1.2.0

解决方法

升级ipykernel 5.3.4似乎已为我修复。

pip install --upgrade ipykernel

请确保随后重新启动Juptyer服务器。

我通过在breakpoint()插入/ipkernel.py:287并使用w来查看是什么来解决这个问题。如果此修复方法对您不起作用,则值得检查您的情况是什么导致呼叫。

,

此处与ipykernel == 5.3.4和ipython == 7.19.0相同。 降级到ipython 7.10.0可以解决此问题。

pip install install ipython==7.10.0

(可选)用于抑制DeprecationWarnings:

import warnings
warnings.filterwarnings("ignore",category=DeprecationWarning)
,

在默认为 conda-forge 存储库的 conda 环境中,与 python==3.9.2、ipykernel==5.5.0 和 ipython==7.21.0 相同。将 ipykernel 升级到最新的 5.5.3 并不能解决任何问题。

当前链接到 this ipykernel issue