How to replace “from IPython.kernel import KernelManager”?

此生再无相见时 提交于 2021-02-19 06:35:26

问题


I have some code which tries to import a KernalManager from IPython, but I get a Warning

/home/alex/Projects/VETests/ipyrunner/local/lib/python2.7/site-packages/IPython/kernel/__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated since IPython 4.0.You should import from ipykernel or jupyter_client instead.
  "You should import from ipykernel or jupyter_client instead.", ShimWarning)

but when I do the following

from ipykernel import KernelManager

I get an error

ImportError: cannot import name KernelManager

How to do it right?


回答1:


Replace

from IPython.kernel import KernelManager/from ipykernel import KernelManager

with

from jupyter_client.manager import KernelManager.



来源:https://stackoverflow.com/questions/46546026/how-to-replace-from-ipython-kernel-import-kernelmanager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!