因为一些原因,卸载了Anaconda2的版本,转向3..发现Jupyter挂了.百思不得其解.后来了解到是因为内核找不到的问题导致的.这里整理了一下处理办法
错误内容:
Traceback (most recent call last): File "c:\program files\python36\lib\site-packages\tornado\web.py", line 1543, in _execute result = yield result File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 1099, in run value = future.result() File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 1107, in run yielded = self.gen.throw(*exc_info) File "c:\program files\python36\lib\site-packages\notebook\services\sessions\handlers.py", line 73, in post type=mtype)) File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 1099, in run value = future.result() File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 1107, in run yielded = self.gen.throw(*exc_info) File "c:\program files\python36\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 79, in create_session kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name) File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 1099, in run value = future.result() File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 1107, in run yielded = self.gen.throw(*exc_info) File "c:\program files\python36\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 92, in start_kernel_for_session self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name) File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 1099, in run value = future.result() File "c:\program files\python36\lib\site-packages\tornado\gen.py", line 315, in wrapper yielded = next(result) File "c:\program files\python36\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 148, in start_kernel super(MappingKernelManager, self).start_kernel(**kwargs) File "c:\program files\python36\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel km.start_kernel(**kwargs) File "c:\program files\python36\lib\site-packages\jupyter_client\manager.py", line 259, in start_kernel **kw) File "c:\program files\python36\lib\site-packages\jupyter_client\manager.py", line 204, in _launch_kernel return launch_kernel(kernel_cmd, **kw) File "c:\program files\python36\lib\site-packages\jupyter_client\launcher.py", line 128, in launch_kernel proc = Popen(cmd, **kwargs) File "c:\program files\python36\lib\subprocess.py", line 709, in __init__ restore_signals, start_new_session) File "c:\program files\python36\lib\subprocess.py", line 997, in _execute_child startupinfo) FileNotFoundError: [WinError 2] 系统找不到指定的文件。
解决办法
首先使用jupyter kernelspec list查看安装的内核和位置
2.进入安装内核目录打开kernel.jason文件,查看Python编译器的路径是否正确(其实笔者的问题就是因为路径不正确导致的),修改错误的这个配置.
3.重启jupyter notebook即可
网络上一些其他解决办法
1.首先使用jupyter kernelspec list查看安装的内核和位置
2.进入安装内核目录打开kernel.jason文件,查看Python编译器的路径是否正确
如果不正确python -m ipykernel install --user重新安装内核,如果有多个内核,如果你使用conda create -n python2 python=2,为Python2.7设置conda变量,那么在anacoda下使用activate pyhton2切换python环境,重新使用python -m ipykernel install --user安装内核
3.重启jupyter notebook即可
补充知识:关于jupyter内核(kernel)错误处理方法
首先明确起因:
卸载重装,或者之前有装过ipython,导致再次安装后,内核匹配的路径错误,没有指向新安装的位置。理论上有两种处理方法:
方法一:
手动修改路径:
1.首先使用jupyter kernelspec list查看安装的内核和位置
2.进入安装内核目录打开kernel.jason文件,查看Python编译器的路径 是否正确(其实笔者的问题就是因为路径不正确导致的),修改错误的这个配置.
3.重启jupyter notebook即可
注:理论上没有问题,但是我在实践的时候没有查找到这个文件,可能是版本问题,如果有经验的话,这个方法比较快捷。
方法二:
暴力重装:
暴力的意思就是彻底重装,之前我有试过sudo pip3,sudo -H以及一些其他方法,但是没有效果。
以下方法最后解决了我的问题:
sudo pip3 install --upgrade --force-reinstall --no-cache-dir jupyter
以上这篇解决Jupyter因卸载重装导致的问题修复就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。