Jupyter 笔记本显示 FileNotFoundError 并且无法 运行 任何 shell

Jupyter notebook shows FileNotFoundError and is unable to run any shell

我已经安装了 Jupyter:

OS : 32bit windows 7

jupyter notebook version is 6.0.1.

安装后,当我尝试打开笔记本时,显示内核错误:

Traceback (most recent call last):
  File "E:\Jupyter\miniconda3\lib\site-packages\tornado\web.py", line 1703, in _execute
    result = await result
  File "E:\Jupyter\miniconda3\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "E:\Jupyter\miniconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
    type=mtype))
  File "E:\Jupyter\miniconda3\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "E:\Jupyter\miniconda3\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "E:\Jupyter\miniconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
    kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
  File "E:\Jupyter\miniconda3\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "E:\Jupyter\miniconda3\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "E:\Jupyter\miniconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
    self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
  File "E:\Jupyter\miniconda3\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "E:\Jupyter\miniconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
    yielded = next(result)
  File "E:\Jupyter\miniconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "E:\Jupyter\miniconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "E:\Jupyter\miniconda3\lib\site-packages\jupyter_client\manager.py", line 259, in start_kernel
    **kw)
  File "E:\Jupyter\miniconda3\lib\site-packages\jupyter_client\manager.py", line 204, in _launch_kernel
    return launch_kernel(kernel_cmd, **kw)
  File "E:\Jupyter\miniconda3\lib\site-packages\jupyter_client\launcher.py", line 138, in launch_kernel
    proc = Popen(cmd, **kwargs)
  File "E:\Jupyter\miniconda3\lib\subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "E:\Jupyter\miniconda3\lib\subprocess.py", line 1207, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

因此,我无法使用 Jupyter 运行 任何东西。 如何解决?

这是您的环境问题。调试方法如下:

检查 Jupyter 配置中指定的内核(参见 Linux 上的 %APPDATA%\jupyter\kernels\<kernel_name>\kernel.json / ~/.local/share/jupyter/kernels/<kernel_name>/kernel.json)是否可通过命令行启动。

例如在我的 kernel.json 文件中,有:

{
 "argv": [
  "/home/mrmino/.virtualenvs/taf/bin/python3.7",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3",
 "language": "python"
}

因此,在我的系统上,命令 /home/mrmino/.virtualenvs/taf/bin/python3.7 -m ipykernel_launcher 应该启动 ipython 内核。

如果您的没有,您必须安装它或在 JSON kernelspec 文件中手动更正它。

试试这个,对我有用。

python3 -m ipykernel install --user

参考:https://github.com/jupyter/notebook/issues/2563