python Jupityr笔记本内核错误- FileNotFoundError:[WinError 2]

w6lpcovy  于 2023-05-12  发布在  Python
关注(0)|答案(6)|浏览(145)

我最近在Anaconda上的一些库遇到了一些问题,所以我重新安装了Anaconda,当我再次启动它时,Jupityr Notebook内核错误发现了以下文本:

Traceback (most recent call last):
  File "C:\Users\Steven\Anaconda3\lib\site-packages\tornado\web.py", line 1543, in _execute
    result = yield result
  File "C:\Users\Steven\Anaconda3\lib\site-packages\tornado\gen.py", line 1099, in run
    value = future.result()
  File "C:\Users\Steven\Anaconda3\lib\site-packages\tornado\gen.py", line 1107, in run
    yielded = self.gen.throw(*exc_info)
  File "C:\Users\Steven\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 73, in post
    type=mtype))
  File "C:\Users\Steven\Anaconda3\lib\site-packages\tornado\gen.py", line 1099, in run
    value = future.result()
  File "C:\Users\Steven\Anaconda3\lib\site-packages\tornado\gen.py", line 1107, in run
    yielded = self.gen.throw(*exc_info)
  File "C:\Users\Steven\Anaconda3\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:\Users\Steven\Anaconda3\lib\site-packages\tornado\gen.py", line 1099, in run
    value = future.result()
  File "C:\Users\Steven\Anaconda3\lib\site-packages\tornado\gen.py", line 1107, in run
    yielded = self.gen.throw(*exc_info)
  File "C:\Users\Steven\Anaconda3\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:\Users\Steven\Anaconda3\lib\site-packages\tornado\gen.py", line 1099, in run
    value = future.result()
  File "C:\Users\Steven\Anaconda3\lib\site-packages\tornado\gen.py", line 315, in wrapper
    yielded = next(result)
  File "C:\Users\Steven\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 148, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "C:\Users\Steven\Anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "C:\Users\Steven\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 259, in start_kernel
    **kw)
  File "C:\Users\Steven\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 204, in _launch_kernel
    return launch_kernel(kernel_cmd, **kw)
  File "C:\Users\Steven\Anaconda3\lib\site-packages\jupyter_client\launcher.py", line 128, in launch_kernel
    proc = Popen(cmd, **kwargs)
  File "C:\Users\Steven\Anaconda3\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Steven\Anaconda3\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

当我启动并打开一个文件时,我得到这个错误。它拒绝运行代码,只是坐在那里有点死了。内核错误出现在几乎所有使用Jupyter notebook打开的文件中。

cs7cruho

cs7cruho1#

下面的解决方案对我很有效。您可以在虚拟环境中的命令提示符或Anaconda提示符中运行此代码。

python -m ipykernel install --user

详细的解释和说明请看这里。

5q4ezhmt

5q4ezhmt2#

  • 打开Anaconda提示
  • 激活您的env
  • type:python -m ipykernel install --user
  • 开始你的jupyter笔记本
e4yzc0pl

e4yzc0pl3#

此解决方案可能对Windows用户有帮助。

  1. pip uninstall jupyter
    1.转到~\AppData\Roaming(AppData是一个隐藏文件)并删除名为jupyterpython的文件夹(如果存在)。
    1.删除~\.jupyter~\.ipython
  2. jupyter安装
    我使用的是Jupiter而不是Anaconda,这完美地解决了这个问题。不知道这是否适用于木星与水蟒。
    我用了这个技巧,它为我工作,我也使用木星没有水蟒。
jei2mxaa

jei2mxaa4#

我也遇到了同样的问题,这个快速解决方案解决了我的问题

pip3 install --upgrade --force-reinstall --no-cache-dir jupyter

参考:Cannot uninstall requirement jupyter, not installed

yvgpqqbh

yvgpqqbh5#

遇到了同样的事情,但答案对我来说出奇的简单:我使用VSCode来执行一些生成图形的代码,虽然我指定了figsize(16,9),但在Jupyter Notebook中图形太大了。
在jupyter notebook里重新运行了一遍,一切正常。

oprakyz7

oprakyz76#

我也有同样的问题。对我有用的是python -m ipykernel install --user --name(在此处插入您的env名称)。我现在可以在虚拟环境中打开Jupyter Notebook了。

相关问题