Cannot import JupyterNotebooksLib

Hi,

To install the JupyterNotebook extension on Slicer and to add a Slicer kernel on Jupyter I followed the steps on https://github.com/Slicer/SlicerJupyter/blob/master/README.md#setup.

After I tried in the new Slicer kernel import JupyterNotebooksLib as slicernb, I got ModuleNotFoundError: No module named ‘JupyterNotebooksLib’.

I’m using Slicer 4.11, Windows10, Anaconda with different version of Python (3.7) than which is used by Slicer (3.6).

During the installation steps I encountered a problem with installing the jupyter lab:
PS C:\User> conda install -c conda-forge nodejs
Traceback (most recent call last):
File “C:\ProgramData\Anaconda3\Scripts\conda-script.py”, line 11, in
from conda.cli import main
ModuleNotFoundError: No module named ‘conda’

Is this a Python version or a path problem?

Can you post a screenshot?
Make sure you select “Slicer-4.11” as Jupyter kernel.

This error is not related to Slicer, but to your conda install. Make sure you activate your virtual environment before you attempt to run any script (simply starting a command prompt in the Scripts folder is not enough).

Thanks for the reply.

I created and activated a python virtual environment via command prompt (run as admin) and have run all lines from the tutorial, including:

conda install -c conda-forge nodejs
pip install ipywidgets ipyevents ipycanvas
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install @jupyter-widgets/jupyterlab-manager ipycanvas
jupyter labextension install @jupyter-widgets/jupyterlab-manager ipyevents

This time it seemed to be installed, but I still get the same error message when trying to import the module in a new kernel:

Did you choose the “Slicer-4.11” kernel in the notebook?

Yes, I did.

Could it be that my python virtual environment wasn’t in the Slicer directory?

Are other Slicer features available? For example, do you have access to slicer.util.getNode function? When you started the kernel, did a Slicer application instance start? Can you post a screenshot of your entire browser window (not just a single cell)?

Slicer application does start with kernel.
I have access to multiple Slicer features (including slicer.util.getNode) too:

other_modules

Which Slicer version are you using? Can you copy here the full application log (menu: Help / Report a bug) here?

[DEBUG][Qt] 10.06.2020 17:37:35 [] (unknown:0) - Session start time …: 2020-06-10 17:37:35
[DEBUG][Qt] 10.06.2020 17:37:35 [] (unknown:0) - Slicer version …: 4.11.0-2020-05-04 (revision 29031 / 88bff56) win-amd64 - installed release
[DEBUG][Qt] 10.06.2020 17:37:35 [] (unknown:0) - Operating system …: Windows / Personal / (Build 18362, Code Page 65001) - 64-bit
[DEBUG][Qt] 10.06.2020 17:37:35 [] (unknown:0) - Memory …: 4001 MB physical, 11169 MB virtual
[DEBUG][Qt] 10.06.2020 17:37:35 [] (unknown:0) - CPU …: GenuineIntel , 4 cores, 4 logical processors
[DEBUG][Qt] 10.06.2020 17:37:35 [] (unknown:0) - VTK configuration …: OpenGL2 rendering, TBB threading
[DEBUG][Qt] 10.06.2020 17:37:35 [] (unknown:0) - Qt configuration …: version 5.10.1, with SSL, requested OpenGL 3.2 (compatibility profile)
[DEBUG][Qt] 10.06.2020 17:37:35 [] (unknown:0) - Developer mode enabled …: no
[DEBUG][Qt] 10.06.2020 17:37:35 [] (unknown:0) - Prefer executable CLI …: yes
[DEBUG][Qt] 10.06.2020 17:37:35 [] (unknown:0) - Application path …: C:/Users/Domi/AppData/Local/NA-MIC/Slicer 4.11.0-2020-05-04/bin
[DEBUG][Qt] 10.06.2020 17:37:35 [] (unknown:0) - Additional module paths …: C:/Users/Domi/AppData/Roaming/NA-MIC/Extensions-29031/SlicerJupyter/lib/Slicer-4.11/qt-loadable-modules
[DEBUG][Python] 10.06.2020 17:38:08 [Python] (C:\Users\Domi\AppData\Local\NA-MIC\Slicer 4.11.0-2020-05-04\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: Annotations
[DEBUG][Python] 10.06.2020 17:38:10 [Python] (C:\Users\Domi\AppData\Local\NA-MIC\Slicer 4.11.0-2020-05-04\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: SegmentEditor
[DEBUG][Python] 10.06.2020 17:38:10 [Python] (C:\Users\Domi\AppData\Local\NA-MIC\Slicer 4.11.0-2020-05-04\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: SegmentStatistics
[DEBUG][Qt] 10.06.2020 17:38:11 [] (unknown:0) - Switch to module: “Welcome”

Can you do this in the Slicer instance that Jupyter started? (it shows a read message in the status bar that this instance is controlled by Jupyter)

Does this file exist on your computer?
c:\Users\Domi\AppData\Roaming\NA-MIC\Extensions-29031\SlicerJupyter\Lib\Slicer-4.11\qt-scripted-modules\JupyterNotebooksLib\__init__.py

You may also try to reinstall SlicerJupyter and extension and make sure that installation is completed (do not press “Close” button while the extension is being installed but wait for the “Restart” button to appear and click that).

I reinstalled the extension properly waiting for the restart button to pop up when I tried to figure out what was wrong.

On the other hand the whole qt-scripted-modules folder is missing.
Should I reinstall Slicer?

The bug report with the Kernel open:
[DEBUG][Python] 10.06.2020 19:05:18 [Python] (C:\Users\Domi\AppData\Local\NA-MIC\Slicer 4.11.0-2020-05-04\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: Annotations
[DEBUG][Python] 10.06.2020 19:05:21 [Python] (C:\Users\Domi\AppData\Local\NA-MIC\Slicer 4.11.0-2020-05-04\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: SegmentEditor
[DEBUG][Python] 10.06.2020 19:05:21 [Python] (C:\Users\Domi\AppData\Local\NA-MIC\Slicer 4.11.0-2020-05-04\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: SegmentStatistics
[DEBUG][Qt] 10.06.2020 19:05:00 (unknown:0) - Session start time …: 2020-06-10 19:05:00
[DEBUG][Qt] 10.06.2020 19:05:00 (unknown:0) - Slicer version …: 4.11.0-2020-05-04 (revision 29031 / 88bff56) win-amd64 - installed release
[DEBUG][Qt] 10.06.2020 19:05:01 (unknown:0) - Operating system …: Windows / Personal / (Build 18362, Code Page 65001) - 64-bit
[DEBUG][Qt] 10.06.2020 19:05:01 (unknown:0) - Memory …: 4001 MB physical, 11169 MB virtual
[DEBUG][Qt] 10.06.2020 19:05:01 (unknown:0) - CPU …: GenuineIntel , 4 cores, 4 logical processors
[DEBUG][Qt] 10.06.2020 19:05:01 (unknown:0) - VTK configuration …: OpenGL2 rendering, TBB threading
[DEBUG][Qt] 10.06.2020 19:05:01 (unknown:0) - Qt configuration …: version 5.10.1, with SSL, requested OpenGL 3.2 (compatibility profile)
[DEBUG][Qt] 10.06.2020 19:05:01 (unknown:0) - Developer mode enabled …: no
[DEBUG][Qt] 10.06.2020 19:05:01 (unknown:0) - Prefer executable CLI …: yes
[DEBUG][Qt] 10.06.2020 19:05:01 (unknown:0) - Application path …: C:/Users/Domi/AppData/Local/NA-MIC/Slicer 4.11.0-2020-05-04/bin
[DEBUG][Qt] 10.06.2020 19:05:01 (unknown:0) - Additional module paths …: C:/Users/Domi/AppData/Roaming/NA-MIC/Extensions-29031/SlicerJupyter/lib/Slicer-4.11/qt-loadable-modules
[DEBUG][Qt] 10.06.2020 19:05:22 (unknown:0) - Switch to module: “Welcome”
[INFO][Stream] 10.06.2020 19:05:24 (unknown:0) - Jupyter connection file: [C:\Users\Domi\AppData\Roaming\jupyter\runtime\kernel-41b84ba5-d377-4f67-8d20-c9f56752253c.json]
[DEBUG][Qt] 10.06.2020 19:05:29 (unknown:0) - Starting Jupyter kernel server

Yes, please install the latest Slicer Preview Release, I cannot check it anymore what the extension package contained in the 2020-05-04 version, there might have been some problem with the nightly build that day.

I installed the latest Slicer 4.11 release and the problem’s solved!

Thank you so much for your help.

1 Like