欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Jupyter Notebook:kernel error 解决

程序员文章站 2022-05-29 09:12:02
...

Jupyter Notebook出现kernel error
当时用Anaconda安装多个版本的Python的时候,时常由于安装和卸载多次Python导致Juoyter notebook不可用。常常导致如下结果

File”//anaconda/lib/python2.7/site-packages/jupyter_client/manager.py”, line 190, in _launch_kernel 
return launch_kernel(kernel_cmd, **kw) 
File “//anaconda/lib/python2.7/site-packages/jupyter_client/launcher.py”, line 123, in launch_kernel 
proc = Popen(cmd, **kwargs) 
File “//anaconda/lib/python2.7/subprocess.py”, line 710, in init 
errread, errwrite) 
File “//anaconda/lib/python2.7/subprocess.py”, line 1335, in _execute_child 
raise child_exception 
OSError: [Errno 2] No such file or director

解决办法

  • 运行python -m ipykernel install --user重新安装内核
  • 如果有多个内核,先运行conda create -n python2 python=2,为Python2.7设置Anaconda变量,在Anacoda下使用activate pyhton2切换python环境
  • 重启jupyter notebook即可

小技巧

jupyter kernelspec list 查看安装的内核和位置
进入安装内核目录打开kernel.jason文件,查看Python编译器的路径

转载于:https://www.jianshu.com/p/de39b46a978d