SlicerJupyter build failed on MacOSX due to failed building wheel for argon2-cffi

MacOS: 11.6
3D Slicer build version: 4.13.0

I can install jupyterlab from Slicer python kernel and argon2-cffi is successfully installed. But when making a build for SlicerJupyter, argon2-cffi build is failed.

Here is the build log:

[  1%] Creating directories for 'python-packages'
[  2%] No download step for 'python-packages'
[  3%] Generate version-python-packages.txt and license-python-packages.txt
[  4%] No update step for 'python-packages'
[  6%] No patch step for 'python-packages'
[  7%] No configure step for 'python-packages'
[  8%] No build step for 'python-packages'
[  9%] Performing install step for 'python-packages'
Collecting jedi==0.18.0
  Using cached jedi-0.18.0-py2.py3-none-any.whl (1.4 MB)
Collecting argon2-cffi==20.1.0
  Using cached argon2-cffi-20.1.0.tar.gz (1.8 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting parso<0.9.0,>=0.8.0
  Using cached parso-0.8.2-py2.py3-none-any.whl (94 kB)
Collecting six
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting cffi>=1.0.0
  Using cached cffi-1.14.6-cp36-cp36m-macosx_10_9_x86_64.whl (176 kB)
Collecting pycparser
  Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
Building wheels for collected packages: argon2-cffi
  Building wheel for argon2-cffi (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/documents/Slicer/build/python-install/bin/./python /Users/documents/Slicer/build/python-install/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/ build_wheel /var/folders/_k/fjl1stps49q7q8lxvnx447hm0000gn/T/tmpikzho0io
       cwd: /private/var/folders/_k/fjl1stps49q7q8lxvnx447hm0000gn/T/pip-install-4o978ieo/argon2-cffi_515aaeab54504515917372aa03f299b2
  Complete output (27 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.13-x86_64-3.6
  creating build/lib.macosx-10.13-x86_64-3.6/argon2
  copying src/argon2/ -> build/lib.macosx-10.13-x86_64-3.6/argon2
  copying src/argon2/ -> build/lib.macosx-10.13-x86_64-3.6/argon2
  copying src/argon2/ -> build/lib.macosx-10.13-x86_64-3.6/argon2
  copying src/argon2/ -> build/lib.macosx-10.13-x86_64-3.6/argon2
  copying src/argon2/ -> build/lib.macosx-10.13-x86_64-3.6/argon2
  copying src/argon2/ -> build/lib.macosx-10.13-x86_64-3.6/argon2
  copying src/argon2/ -> build/lib.macosx-10.13-x86_64-3.6/argon2
  copying src/argon2/ -> build/lib.macosx-10.13-x86_64-3.6/argon2
  running build_clib
  building 'argon2' library
  creating build/temp.macosx-10.13-x86_64-3.6
  creating build/temp.macosx-10.13-x86_64-3.6/extras
  creating build/temp.macosx-10.13-x86_64-3.6/extras/libargon2
  creating build/temp.macosx-10.13-x86_64-3.6/extras/libargon2/src
  creating build/temp.macosx-10.13-x86_64-3.6/extras/libargon2/src/blake2
  /Applications/ -Wall -g -fPIC -msse2 -Iextras/libargon2/src/../include -Iextras/libargon2/src/blake2 -c extras/libargon2/src/argon2.c -o build/temp.macosx-10.13-x86_64-3.6/extras/libargon2/src/argon2.o
  extras/libargon2/src/argon2.c:18:10: fatal error: 'string.h' file not found
  #include <string.h>
  1 error generated.
  error: command '/Applications/' failed with exit status 1
  ERROR: Failed building wheel for argon2-cffi
Failed to build argon2-cffi
ERROR: Could not build wheels for argon2-cffi which use PEP 517 and cannot be installed directly
WARNING: You are using pip version 21.1.2; however, version 21.2.4 is available.
You should consider upgrading via the '/Users/ruooo/documents/Slicer/build/python-install/bin/./python -m pip install --upgrade pip' command.
make[2]: *** [python-packages-prefix/src/python-packages-stamp/python-packages-install] Error 1
make[1]: *** [CMakeFiles/python-packages.dir/all] Error 2
make: *** [all] Error 2

AFAIK this is a mac-only issue that will resolve itself once Slicer upgrades to a higher version of python which is hopefully soon.

In the mean time if you install Jupyter Lab outside of 3D Slicer and install the Slicer Jupyter kernel into it - it’s going to work nicely. To install the Slicer Jupyter Kernel into a lab environment use the snippet in the JupyterKernel extension

Can you explain more on how to install the JupyterKernel extension? Is this installed in Slicer or JupyterLab outside the Slicer env?

This is the procedure that worked for me. It is required to be performed only once.

  1. Install the latest Slicer nightly

  2. Install the SlicerJupyter extension from the extension manager in Slicer

  3. Create and activate a python3 virtual environment outside of Slicer. Let’s call it myJupyterEnvironment.

  4. Install Jupyter Lab into myJupyterEnvironment with
    pip install jupyterlab

  5. Open the JupyterKernel module in Slicer

  6. Copy the command that’s displayed in the “Jupyter server in external Python environment” section and execute it in myJupyterEnvironment

This command will install a Slicer kernel into your Jupyter lab. You can check that the extension has been installed by running jupyter-kernelspec list

  1. Launch Jupyter Lab by running jupyter lab in myJupyterEnvironment. You’ll see “S” 2 icons. The orange one creates a notebook in the Slicer kernel and the blue one creates a kernel console

  2. Click on the notebook icon to connect to a kernel. A Slicer window will be created hidden in the dock. Pop it out if you need to access the UI.

Thanks, this works for me too when I install the dmg file! However, I need to build the slicer from the source code, somehow the extension manager is not working after being built, there are no extensions showing. And I cannot install the SlicerJupyter extension from there. Then this leads to my original question.

When you build Slicer from source you are also expected to build extensions from source as well. You can at times use extensions built from the Slicer factory build machines if you have built the same revision as one of the Slicer factory builds. However you can potentially run into incompatibilities

Is it enough to set the
option(Slicer_BUILD_EXTENSIONMANAGER_SUPPORT "Build Slicer extensions manager" ON)
parameter in the CMakeLists.txt to have the extension manager working?

That will build the extension manager, but the question of will there be any extensions from the server to choose from depends on the revision of Slicer that is built (one that matches latest stable or a preview build).

For example, if you have checked out the commit that is ENH: Improve resolution of splashscreen and welcome icon which was the first commit of several commits on Sept 22nd, then you won’t see any Slicer factory built extensions in the Extensions Manager since it won’t correspond to the revision of a Slicer Preview build (latest commit prior to 11pm EST). You would have to manually build extensions and could package those extensions and manually install using the Extensions Manager.

1 Like

Thanks for the clarification