How to start Slicer Jupyter kernel?

Dear Andras,
I installed the JupyterKernel but I receive error output as below:

Then I launched jupyter through anaconda. it looks like as below:

I have 4.9 nighly version of slicer which I dont see here.

Please guide.
Thank you

Regards,
Saima Safdar

I’ve improved module documentation - see https://github.com/Slicer/SlicerJupyter/blob/master/README.md

If the instructions are still not clear enough then let us know.

Dear Andras,
I am getting these errors.

Please help in fixing.

Regards,
Saima Safdar

I only see a small part of the error message. Could you please copy-paste the content of the error box? Could you please also copy the Slicer application log (menu: Help / Report a bug)?

Yes Please see the errors below:

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

The setup for JupyterKernel

  • Slicer Kernel folder: C:/Users/22374464/AppData/Roaming/NA-MIC/Extensions-27353/SlicerJupyter/share/Slicer-4.9/qt-loadable-modules/JupyterKernel/Slicer-4.9
  • Python Scripts folder: D:/anaconda/Scripts

Log from slicer warning message:

Kernelspec install error output:
[InstallKernelSpec] Removing existing kernelspec in C:\\Users\\22374464\\AppData\\Roaming\\jupyter\\kernels\\slicer-4.9
[InstallKernelSpec] Installed kernelspec slicer-4.9 in C:\\Users\\22374464\\AppData\\Roaming\\jupyter\\kernels\\slicer-4.9

Is this build version? It is high probability that I have got similar error. I have a built version of Slicer and then need to build SlicerJupiter. Then I copied the files:

cp -r /home/broncho/SlicerExtensions/SlicerJupyter-build/inner-build/lib/Slicer-4.9 /home/software/medical/slicer4.9/Slicer-SuperBuild-Release/Slicer-build/share/
cp -r /home/broncho/SlicerExtensions/SlicerJupyter-build/lib/Slicer-4.9 /home/software/medical/slicer4.9/Slicer-SuperBuild-Release/Slicer-build/lib/

Didn’t working without copied libraries from inner-build.

Then in Slicer I have selected Jupyter directiory(virtual environment).
This information may be useful.

no its not build version

@saima Can you copy here the contents of the file C:\Users\22374464\AppData\Roaming\jupyter\kernels\slicer-4.9\kernel.json?

Please see the contents of file kernel.json

{
    "display_name": "Slicer 4.9",
    "language" : "python",
    "argv": [
        "C:/Program Files/Slicer 4.9.0-2018-08-17/bin/../Slicer.exe",
        "--no-splash",
        "--python-code",
        "connection_file=r'{connection_file}'; print('Jupyter connection file: ['+connection_file+']'); slicer.modules.jupyterkernel.startKernel(connection_file);slicer.util.mainWindow().showMinimized()"
    ]
}

Does Slicer start if you type this on the command-line?

C:/Program Files/Slicer 4.9.0-2018-08-17/bin/../Slicer.exe

Could you please also try with the latest nightly build (that you’ve downloaded just now)? Install SlicerJupyter extension, install the kernel, restart Jupyter, create a new notebook with Slicer-4.9 kernel.

Dear Andras,
The file slicer.exe is at location: D:\Slicer4.9\Slicer 4.9.0-2018-08-17
Its not at C:/Program Files/Slicer 4.9.0-2018-08-17/bin/…/Slicer.exe.

Should I change the script manually? or should I reinstall in C drive

Yes I tried with the latest nightly build.

Yes, changing the path in kernel.json file should fix the issue.

Did you move Slicer manually from C:\Program Files\... to D:\Slicer4.9\...?

no I didnt I installed on D drive.
Yes its connected now.

Why the path was not correct?

Thank you so much Andras

Dear Andras can I have code completion in this.

I’ve checked the implementation and kernel.json was only updated once, when a specific Slicer version was installed the first time. You’ve installed first on the C drive and then when you uninstalled and reinstalled it on D drive, the program path in the kernel file still pointed to the deleted installation.

I’ve pushed a fix - now kernel.json is updated whenever the kernel is installed. So, the error should not occur anymore for SlicerJupyter versions that you download tomorrow or later.

1 Like

Yes I followed the steps you mentioned. Kernel is running but I dont get the auto complete. I changed the path manually. Should I install again the slicer and the extensions.

Yes, you will need to update to get new fixes/features.

1 Like

To make sure that your kernel is using the latest Slicer version, please enter the following into a cell in your Jupyter notebook, run it, and let us know what version do you get:

print slicer.app.applicationVersion

Its 4.9.0-2018-08-17

That version did not contain auto-complete yet. You need to install latest nightly version and reinstall the extension and kernel as described above.

1 Like

Hi everyone.

I am trying to prepare the environment for my friend but when running the jupyter kernel Slicer exit abnormally. I followed instruction from github.
I downloaded stable Slicer then installed SlicerJupyter(it didn’t appear in modules then manually copy libs). What am I doing wrong?

Greetings.