# Cannot import JupyterNotebooksLib

**URL:** <https://discourse.slicer.org/t/cannot-import-jupyternotebookslib/11967>\
**Category:** Support\
**Created:** [June 9, 2020, 6:25pm UTC](https://discourse.slicer.org/t/cannot-import-jupyternotebookslib/11967 "2020-06-09T18:25:42Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ponyo2311](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ponyo2311/32/7078_2.png) [@Ponyo2311](https://discourse.slicer.org/u/Ponyo2311)\
**Post date:** [June 9, 2020, 6:25pm UTC](https://discourse.slicer.org/t/cannot-import-jupyternotebookslib/11967/1 "2020-06-09T18:25:42Z")

</div>

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](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?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 9, 2020, 9:15pm UTC](https://discourse.slicer.org/t/cannot-import-jupyternotebookslib/11967/2 "2020-06-09T21:15:59Z")

</div>

> [@Ponyo2311](#):
>
> After I tried in the new Slicer kernel _ **import JupyterNotebooksLib** as slicernb_ , I got

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

> [@Ponyo2311](#):
>
> 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’_

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).

---

<div class="post-metadata">

**Author:** ![Ponyo2311](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ponyo2311/32/7078_2.png) [@Ponyo2311](https://discourse.slicer.org/u/Ponyo2311)\
**Post date:** [June 10, 2020, 10:14am UTC](https://discourse.slicer.org/t/cannot-import-jupyternotebookslib/11967/3 "2020-06-10T10:14:04Z")

</div>

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:

 ![error_message](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/8/186900e60485972bb13df11c8eca6f5534d8a3be.jpeg)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 10, 2020, 12:29pm UTC](https://discourse.slicer.org/t/cannot-import-jupyternotebookslib/11967/4 "2020-06-10T12:29:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ponyo2311](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ponyo2311/32/7078_2.png) [@Ponyo2311](https://discourse.slicer.org/u/Ponyo2311)\
**Post date:** [June 10, 2020, 12:31pm UTC](https://discourse.slicer.org/t/cannot-import-jupyternotebookslib/11967/5 "2020-06-10T12:31:38Z")

</div>

Yes, I did.

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

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 10, 2020, 12:34pm UTC](https://discourse.slicer.org/t/cannot-import-jupyternotebookslib/11967/6 "2020-06-10T12:34:05Z")

</div>

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)?

---

<div class="post-metadata">

**Author:** ![Ponyo2311](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ponyo2311/32/7078_2.png) [@Ponyo2311](https://discourse.slicer.org/u/Ponyo2311)\
**Post date:** [June 10, 2020, 3:04pm UTC](https://discourse.slicer.org/t/cannot-import-jupyternotebookslib/11967/7 "2020-06-10T15:04:33Z")

</div>

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

![other_modules](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/0/e0da95d25c2edd44bbc84750a34740e470393bdc.png)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 10, 2020, 3:25pm UTC](https://discourse.slicer.org/t/cannot-import-jupyternotebookslib/11967/8 "2020-06-10T15:25:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ponyo2311](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ponyo2311/32/7078_2.png) [@Ponyo2311](https://discourse.slicer.org/u/Ponyo2311)\
**Post date:** [June 10, 2020, 3:50pm UTC](https://discourse.slicer.org/t/cannot-import-jupyternotebookslib/11967/9 "2020-06-10T15:50:01Z")

</div>

[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”

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 10, 2020, 4:31pm UTC](https://discourse.slicer.org/t/cannot-import-jupyternotebookslib/11967/10 "2020-06-10T16:31:43Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Ponyo2311](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ponyo2311/32/7078_2.png) [@Ponyo2311](https://discourse.slicer.org/u/Ponyo2311)\
**Post date:** [June 10, 2020, 5:11pm UTC](https://discourse.slicer.org/t/cannot-import-jupyternotebookslib/11967/11 "2020-06-10T17:11:06Z")

</div>

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?

 ![missing_folder](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/3/13eace2f24fdf53617572f70744ea0f16c68ff22.jpeg)

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

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 10, 2020, 5:23pm UTC](https://discourse.slicer.org/t/cannot-import-jupyternotebookslib/11967/12 "2020-06-10T17:23:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ponyo2311](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ponyo2311/32/7078_2.png) [@Ponyo2311](https://discourse.slicer.org/u/Ponyo2311)\
**Post date:** [June 10, 2020, 8:33pm UTC](https://discourse.slicer.org/t/cannot-import-jupyternotebookslib/11967/13 "2020-06-10T20:33:23Z")

</div>

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

Thank you so much for your help.
