【问题标题】:Ipython notebook, how to set the correct path to kernelIpython笔记本,如何设置正确的内核路径
【发布时间】:2016-01-13 09:17:10
【问题描述】:

在 Windows 7 64 位上运行 ipyhton 笔记本并使用 python 2 内核启动笔记本时出现错误:

Traceback (most recent call last):
  File "C:\Users\USER1\Anaconda2\lib\site-packages\notebook\base\handlers.py", line 436, in wrapper
    result = yield gen.maybe_future(method(self, *args, **kwargs))
  File "C:\Users\USER1\Anaconda2\lib\site-packages\notebook\services\sessions\handlers.py", line 56, in post
    model = sm.create_session(path=path, kernel_name=kernel_name)
  File "C:\Users\USER1\Anaconda2\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 66, in create_session
    kernel_name=kernel_name)
  File "C:\Users\USER1\Anaconda2\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 84, in start_kernel
    **kwargs)
  File "C:\Users\USER1\Anaconda2\lib\site-packages\jupyter_client\multikernelmanager.py", line 109, in start_kernel
    km.start_kernel(**kwargs)
  File "C:\Users\USER1\Anaconda2\lib\site-packages\jupyter_client\manager.py", line 244, in start_kernel
    **kw)
  File "C:\Users\USER1\Anaconda2\lib\site-packages\jupyter_client\manager.py", line 190, in _launch_kernel
    return launch_kernel(kernel_cmd, **kw)
  File "C:\Users\USER1\Anaconda2\lib\site-packages\jupyter_client\launcher.py", line 115, in launch_kernel
    proc = Popen(cmd, **kwargs)
  File "C:\Users\USER1\Anaconda2\lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "C:\Users\USER1\Anaconda2\lib\subprocess.py", line 958, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

我已进一步调查,并在 launcher.py 文件中的 proc = Popen(cmd, **kwargs) 之前添加了以下打印行

    print cmd
    print kwargs

现在我看到 proc = Popen(cmd, **kwargs) 是用 cmd= 调用的

['C:\\Users\\USER1\\Anaconda2_32bit\\python.exe', '-m', 'ipykernel', '-f', '
C:\\Users\\USER1\\AppData\\Roaming\\jupyter\\runtime\\kernel-a3f46334-4491-4
fef-aeb1-6772b8392954.json']

这是一个问题,因为我的 python.exe 不在

C:\\Users\\USER1\\Anaconda2_32bit\\python.exe

但在

C:\\Users\\USER1\\Anaconda2\\python.exe

但是我已经检查了计算机/高级系统设置/高级/环境变量中的路径,并且从未在此处指定 \\Anaconda2_32bit\\

因此,我怀疑在其他地方指定了错误路径。这可能在哪里,我该如何解决?

另外,我之前在 \\Anaconda2_32bit\\ 中安装了 Anaconda,但我已经卸载了它。

【问题讨论】:

    标签: path ipython anaconda jupyter jupyter-notebook


    【解决方案1】:

    ipython 在特殊配置文件中注册了内核 我已经运行了命令:

    ipython kernelspec list
    

    输出是:

    Available kernels:
      python2    C:\ProgramData\jupyter\kernels\python2
    

    我查看了C:\ProgramData\jupyter\kernels\python2\kernel.json 文件,为 python2 设置了错误的路径。我已经修复了路径,现在可以使用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-29
      • 2014-11-27
      • 1970-01-01
      • 1970-01-01
      • 2023-04-09
      相关资源
      最近更新 更多