# Slicer/Jupyter integration: installing python packages

**URL:** https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386
**Category:** Support
**Tags:** jupyter
**Created:** [September 8, 2020, 3:23am UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386 "2020-09-08T03:23:06Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![yoomi](https://avatars.discourse-cdn.com/v4/letter/y/a6a055/32.png) [@yoomi](https://discourse.slicer.org/u/yoomi)
#### Post date: [September 8, 2020, 3:23am UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/1 "2020-09-08T03:23:06Z")

</div>

Hello,

I’m having trouble integrating 3D Slicer with Jupyter on my computer. I installed both Slicer and Jupyter, but am stuck on installing python packages. When I paste the below into the python interactor in Slicer as instructed here ([https://github.com/Slicer/SlicerJupyter/blob/master/README.md](https://github.com/Slicer/SlicerJupyter/blob/master/README.md)), I get the error that pip\_install is invalid syntax.

Thanks so much for your help

```auto
import os
if os.name=='nt':
    # There are no official pyzmq wheels for Python-3.6 for Windows, so we have to install manually
    pip_install("https://files.pythonhosted.org/packages/94/e1/13059383d21444caa16306b48c8bf7a62331ca361d553d2119696ea67119/pyzmq-19.0.0-cp36-cp36m-win_amd64.whl")
else:
    # PIL may be corrupted on linux, reinstall from pillow
    pip_install('--upgrade pillow --force-reinstall')
pip_install("ipywidgets pandas ipyevents ipycanvas")

```

---

<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: [September 8, 2020, 3:24am UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/2 "2020-09-08T03:24:00Z")

</div>

What operating system do you use?  
What error message do you get?

---

<div class="post-metadata">

### Author: ![yoomi](https://avatars.discourse-cdn.com/v4/letter/y/a6a055/32.png) [@yoomi](https://discourse.slicer.org/u/yoomi)
#### Post date: [September 8, 2020, 1:27pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/3 "2020-09-08T13:27:26Z")

</div>

I’m on a Mac OS, and the specific error message is

File “”, line 7  
pip\_install(“ipywidgets pandas ipyevents ipycanvas”)  
^  
SyntaxError: invalid syntax

---

<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: [September 8, 2020, 1:32pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/4 "2020-09-08T13:32:31Z")

</div>

Probably the console is confused by the indentations. Either copy-paste the last line separately, or just copy-paste the two lines relevant for macOS:

```auto
pip_install('--upgrade pillow --force-reinstall')
pip_install('ipywidgets pandas ipyevents ipycanvas')

```

---

<div class="post-metadata">

### Author: ![yoomi](https://avatars.discourse-cdn.com/v4/letter/y/a6a055/32.png) [@yoomi](https://discourse.slicer.org/u/yoomi)
#### Post date: [September 8, 2020, 1:49pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/5 "2020-09-08T13:49:47Z")

</div>

Hi Andras,

That gives me the error that  
Traceback (most recent call last):  
File “”, line 1, in   
NameError: name ‘pip\_install’ is not defined

Is there something I should do in addition to “import os” before executing these lines? I’m just following the instructions from the readme.

Thanks so much for your help.

---

<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: [September 8, 2020, 1:51pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/6 "2020-09-08T13:51:28Z")

</div>

You need to copy-paste these lines in 3D Slicer’s Python console.

---

<div class="post-metadata">

### Author: ![yoomi](https://avatars.discourse-cdn.com/v4/letter/y/a6a055/32.png) [@yoomi](https://discourse.slicer.org/u/yoomi)
#### Post date: [September 8, 2020, 1:52pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/7 "2020-09-08T13:52:30Z")

</div>

Is that separate from the python interactor? I’m typing it into the Python interactor at the bottom of the screen

---

<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: [September 8, 2020, 1:57pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/8 "2020-09-08T13:57:00Z")

</div>

Yes, the Python interactor at the bottom of the Slicer application window shows a console of Slicer’s Python environment. Are there any error messages in the console before you type the command? Can you post a screenshot of how everything looks after you typed the command?

Could you try with `slicer.util.pip_install` instead of just `pip_install`?

---

<div class="post-metadata">

### Author: ![yoomi](https://avatars.discourse-cdn.com/v4/letter/y/a6a055/32.png) [@yoomi](https://discourse.slicer.org/u/yoomi)
#### Post date: [September 8, 2020, 2:00pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/9 "2020-09-08T14:00:56Z")

</div>

Hi Andras,

There is no error message before I type the command. Do I need to import pip into this environment before I get started? I tried it with slicer.util.pip\_install, and this is what I get

 ![errormessage](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/c/ac7eb58312d4aaa540538be2f26d2e3d55a0d43f.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: [September 8, 2020, 2:03pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/10 "2020-09-08T14:03:04Z")

</div>

Which Slicer version do you use?

---

<div class="post-metadata">

### Author: ![yoomi](https://avatars.discourse-cdn.com/v4/letter/y/a6a055/32.png) [@yoomi](https://discourse.slicer.org/u/yoomi)
#### Post date: [September 8, 2020, 2:06pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/11 "2020-09-08T14:06:23Z")

</div>

This is 3D slicer 4.10.2

---

<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: [September 8, 2020, 2:07pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/12 "2020-09-08T14:07:58Z")

</div>

OK, that explains everything. You need to use a recent Slicer Preview Release.

---

<div class="post-metadata">

### Author: ![yoomi](https://avatars.discourse-cdn.com/v4/letter/y/a6a055/32.png) [@yoomi](https://discourse.slicer.org/u/yoomi)
#### Post date: [September 8, 2020, 3:27pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/13 "2020-09-08T15:27:03Z")

</div>

Hi Andras,

that worked – thanks! – but now when I try to pip\_install(‘ipywidgets pandas ipyevents ipycanvas’) I get the error that “could not build wheels for argon-cffi which use PEP517 and cannot be installed directly”. Do you know what might be going on?

Thanks

---

<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: [September 8, 2020, 3:34pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/14 "2020-09-08T15:34:07Z")

</div>

Can you copy here the actual error message?

Could you run pip\_install for each package separately to see which one triggers the error?

---

<div class="post-metadata">

### Author: ![yoomi](https://avatars.discourse-cdn.com/v4/letter/y/a6a055/32.png) [@yoomi](https://discourse.slicer.org/u/yoomi)
#### Post date: [September 8, 2020, 3:46pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/15 "2020-09-08T15:46:16Z")

</div>

Pandas has no problem, but ipycanvas, ipywidgets, and ipyevents all give the same error message below, and when I try the command suggested in the warning in terminal, it aborts it

 ![errormessage2](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/4/34982a2dbc1766d8dada7185ebb49a41df610590.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: [September 8, 2020, 4:33pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/16 "2020-09-08T16:33:41Z")

</div>

Thank you for all these information.

I searched for this error on the web and it seems that Jupyter recently switched to argon2-cffi crypto library to increase its security. Unfortunately, this library does not have binary package (wheel) for Python-3.6.7 on MacOS, that’s why you get the error.

You have a few options:

**Option A:** Let anaconda get/build the wheel for you. Install anaconda and type the following commands:

```bash
conda create -n slicerhelper python=3.6.7
conda activate slicerhelper
pip install argon2-cffi

```

After this, pip\_install command in Slicer should succeed.

**Option B.** Find a download site for Python-3.6.7 macOS wheel for argon2-cffi and specify that using pip\_install.

**Option C.** Use a Jupyter version that did not depend on argon2-cffi, by specifying an earlier version of ipywidgets or jupyter in pip\_install

@jcfr Do you have any comment on this? Could we upgrade Slicer to Python-3.7? Or, could we build an argon2-cffi Python-3.6.7 macOS wheel and make it available for download?

---

<div class="post-metadata">

### Author: ![yoomi](https://avatars.discourse-cdn.com/v4/letter/y/a6a055/32.png) [@yoomi](https://discourse.slicer.org/u/yoomi)
#### Post date: [September 8, 2020, 4:42pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/17 "2020-09-08T16:42:16Z")

</div>

Let me give this a try, thank you!

---

<div class="post-metadata">

### Author: ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)
#### Post date: [September 8, 2020, 4:51pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/18 "2020-09-08T16:51:43Z")

</div>

> [@lassoan](#):
>
> Do you have any comment on this? Could we upgrade Slicer to Python-3.7?

While we could work with the upstream `argon2-cffi` project to have wheels, I suggest instead to spend time updating the python version used in Slicer from 3.6 to 3.7 (or 3.8).

This has been discussed here:

- [Update Python version from 3.6.7 to 3.9.10 · Issue #5014 · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/issues/5014)

In the meantime, the community is helping to update from 3.6.7 to 3.6.12:

- [ENH: Change python version to 3.6.12 by BishopWolf · Pull Request #5161 · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/pull/5161)
- [ENH: Added support for python 3.6.8 to 3.6.12 by BishopWolf · Pull Request #270 · python-cmake-buildsystem/python-cmake-buildsystem · GitHub](https://github.com/python-cmake-buildsystem/python-cmake-buildsystem/pull/270)

---

<div class="post-metadata">

### Author: ![yoomi](https://avatars.discourse-cdn.com/v4/letter/y/a6a055/32.png) [@yoomi](https://discourse.slicer.org/u/yoomi)
#### Post date: [September 8, 2020, 5:33pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/19 "2020-09-08T17:33:47Z")

</div>

@lassoan

Option A worked, and I was able to get through the installation instructions on the readme, but now that Jupyter kernel and Slicer are connected, I tested this in Jupyter

```auto
import JupyterNotebooksLib as slicernb
slicernb.ViewDisplay()

```

and got this error message in my terminal, but nothing happens in my Jupyter notebook (no error message) or in Slicer

ERROR: during execute\_request

make\_tuple(): unable to convert arguments to Python object (compile in debug mode for details)

---

<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: [September 8, 2020, 6:28pm UTC](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386/20 "2020-09-08T18:28:58Z")

</div>

I was able to reproduce the issue. Most probably it is because of a recent upgrade of XEUS-Python kernel. I’ll investigate it a bit more and revert to the last known working version if I cannot figure out how to fix it.

[Next page](https://discourse.slicer.org/t/slicer-jupyter-integration-installing-python-packages/13386.md?page=2)
