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

Gia*_*igi 24 python jupyter

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

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)
Run Code Online (Sandbox Code Playgroud)

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

And*_*nes 16

升级ipykernel5.3.4 似乎为我修复了它。

pip install --upgrade ipykernel
Run Code Online (Sandbox Code Playgroud)

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

我通过插入一个breakpoint()at/ipkernel.py:287并使用w来查看调用的内容来想出这个。如果此修复程序对您不起作用,则值得检查一下您的情况。

  • 由于某些奇怪的原因,它对我不起作用:(我最终降级到 7.10。 (2认同)

Tom*_*ski 13

这里与 ipykernel==5.3.4 和 ipython==7.19.0 相同。降级到 ipython 7.10.0 解决了这个问题。

pip install install ipython==7.10.0
Run Code Online (Sandbox Code Playgroud)

可选择用于抑制 DeprecationWarnings:

import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
Run Code Online (Sandbox Code Playgroud)

  • 版本 7.10.0 不适用于 conda,但 7.10.1 可用,并且也解决了我的问题。 (2认同)
  • 对于使用 Python 3.9 的用户,请注意 ipython 7.10.* 仅适用于 Python < 3.9,因此此降级不起作用。 (2认同)