Jupyter Notebook FileNotFoundError: [WinError 2] 系统找不到指定的文件

问题描述:

通过Anaconda新创建环境“tfenv” python=3.5.5

并依次安装tensorflow, ipython,jupyter,matplotlib这三个包及其依赖包。然后在该环境下启动jupyter notebook,当想要新建一个notebook时报错。

Jupyter Notebook FileNotFoundError: [WinError 2] 系统找不到指定的文件_第1张图片

上部菜单栏提示 Kernel error,点开后有如下错误:

Failed to start the kernel.
Traceback (most recent call last):
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\site-packages\tornado\web.py", line 1592, in _execute
    result = yield result
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\asyncio\futures.py", line 294, in result
    raise self._exception
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\site-packages\tornado\gen.py", line 1141, in run
    yielded = self.gen.throw(*exc_info)
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\site-packages\notebook\services\sessions\handlers.py", line 73, in post
    type=mtype))
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\asyncio\futures.py", line 294, in result
    raise self._exception
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\site-packages\tornado\gen.py", line 1141, in run
    yielded = self.gen.throw(*exc_info)
  File "D:\MySoftwares\Anaconda3\envs\tfenv\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 "D:\MySoftwares\Anaconda3\envs\tfenv\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\asyncio\futures.py", line 294, in result
    raise self._exception
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\site-packages\tornado\gen.py", line 1141, in run
    yielded = self.gen.throw(*exc_info)
  File "D:\MySoftwares\Anaconda3\envs\tfenv\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 "D:\MySoftwares\Anaconda3\envs\tfenv\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\asyncio\futures.py", line 294, in result
    raise self._exception
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\site-packages\tornado\gen.py", line 326, in wrapper
    yielded = next(result)
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 160, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\site-packages\jupyter_client\manager.py", line 259, in start_kernel
    **kw)
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\site-packages\jupyter_client\manager.py", line 204, in _launch_kernel
    return launch_kernel(kernel_cmd, **kw)
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\site-packages\jupyter_client\launcher.py", line 138, in launch_kernel
    proc = Popen(cmd, **kwargs)
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\subprocess.py", line 676, in __init__
    restore_signals, start_new_session)
  File "D:\MySoftwares\Anaconda3\envs\tfenv\lib\subprocess.py", line 957, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

同时查看Anaconda Prompt 也报错如下:

[E 12:25:38.580 NotebookApp] Failed to run command:
    ['D:/MySoftwares/Anaconda3/envs/tfenv/bin/python', '-m', 'ipykernel_launcher', '-f', 'C:\\Users\\xlwang\\AppData\\Roaming\\jupyter\\runtime\\kernel-63d96000-e78e-49f0-80c5-e5e6e1a54b27.json']
        PATH='...(这里为自己本机的环境变量PATH中的各种路径)'
        with kwargs:
    {'close_fds': False, 'stderr': None, 'stdout': None, 'cwd': 'C:\\Users\\xlwang', 'stdin': -1}

[E 12:25:38.582 NotebookApp] Uncaught exception POST /api/sessions (::1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri='/api/sessions', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      ......这里和前面Traceback内容一致。

请求涛哥过来,我们一起百度,终于找到问题所在。主要参考的是这篇博客

解决方法:

1、首先在cmd 使用jupyter kernelspec list查看安装的内核和位置。

2、进入安装内核目录打开kernel.jason文件,查看Python编译器的路径是否正确。

{
 "argv": [
  "D:/MySoftwares/Anaconda3/envs/tfenv/bin/python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3",
 "language": "python"
}

3、到实际的文件夹中查看发现/envs/tfenv/下根本没有/bin子目录,python.exe直接就在/tfenv目录下,所以将上面路径中的/bin删去。

4、重启jupyter notebook,错误消失。

 

 

你可能感兴趣的:(Anaconda)