Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ipython notebook, how to set the correct path to kernel

When Running ipyhton notebook on Windows 7 64bit and launching notebook with python 2 kernel I get an error:

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

I have investigated further and I have added following print lines before proc = Popen(cmd, **kwargs) inside launcher.py file

    print cmd
    print kwargs

Now I see that proc = Popen(cmd, **kwargs) is called with 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']

this is a problem because my python.exe is not in

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

but in

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

However I have checked paths in Computer/Advanced system settings/Advanced/Enviroment variables and \\Anaconda2_32bit\\ is never specified there.

Thus I suspect that the false path is specified somewhere else. Where could this be and how can I fix it?

Also I have previously had an installation of Anaconda in \\Anaconda2_32bit\\ but I have uninstalled it.

like image 492
Marcel Avatar asked Sep 18 '25 23:09

Marcel


1 Answers

The ipython has kernels registered in special configuration files I have run the command:

ipython kernelspec list

the output was:

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

I have looked into C:\ProgramData\jupyter\kernels\python2\kernel.json file and there was a wrong path set for python2. I have fixed the path and it works now.

like image 153
Marcel Avatar answered Sep 22 '25 07:09

Marcel