SimpleITK tries to write Python wrapped files into a default folder that needs root privileges

I’m trying to bake Slicer 4.11 from the source and use my system installed Python 3.6. This is my cmake command:

cmake -DCMAKE_INSTALL_PREFIX=/scratch1/yousefi/Slicer-Install/ -DSlicer_USE_SYSTEM_python=ON -DSlicer_USE_SYSTEM_OpenSSL=ON -G Ninja ../Slicer

It just compiles fine until installing step of SimpleITK that shows this error:

[351/362] Performing install step for 'SimpleITK'
-- SimpleITK: Removing 'install' log files
-- SimpleITK: SimpleITK_WORKING_DIR: /scratch1/yousefi/Slicer-SuperBuild-Debug/SimpleITK-build/SimpleITK-build/Wrapping/Python
-- SimpleITK: /bin/python3.6;setup.py;install
-- SimpleITK: Errors detected - See below.
running install

error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 2] No such file or directory: '/usr/local/lib64/python3.6/site-packages/test-easy-install-3462044.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /usr/local/lib64/python3.6/site-packages/

This directory does not currently exist.  Please create it and try again, or
choose a different installation directory (using the -d or --install-dir
option).


CMake Error at /scratch1/yousefi/Slicer/CMake/ExternalProjectForNonCMakeProject.cmake:104 (message):
  SimpleITK: install step failed with exit code '1'.

  Outputs also captured in
  /scratch1/yousefi/Slicer-SuperBuild-Debug/SimpleITK_install_step_output.txt
  and
  /scratch1/yousefi/Slicer-SuperBuild-Debug/SimpleITK_install_step_error.txt.


  Setting env.  variable EP_EXECUTE_DISABLE_CAPTURE_OUTPUTS to 1 allows to
  disable file capture.

Call Stack (most recent call first):
  /scratch1/yousefi/Slicer-SuperBuild-Debug/SimpleITK_install_step.cmake:3 (ExternalProject_Execute)


FAILED: SimpleITK-prefix/src/SimpleITK-stamp/SimpleITK-install 
cd /scratch1/yousefi/Slicer-SuperBuild-Debug/SimpleITK-build && /scratch1/yousefi/cmake-3.18.2-Linux-x86_64/bin/cmake -P /scratch1/yousefi/Slicer-SuperBuild-Debug/SimpleITK_install_step.cmake && /scratch1/yousefi/cmake-3.18.2-Linux-x86_64/bin/cmake -E touch /scratch1/yousefi/Slicer-SuperBuild-Debug/SimpleITK-prefix/src/SimpleITK-stamp/SimpleITK-install
ninja: build stopped: subcommand failed.

It seems that it tries to write some files into the /usr/local/lib64/python3.6/site-packages/ which I don’t have the privilege to write. In fact, I’m not an admin in our cluster. Any idea how to fix it?

There is no benefits in using your own system python. None at all. Try using the bundled python inside slicer.

If you don’t specifically need it you can turn off SimpleITK.

Ideed I use SimpleITK in my workflow and I don’t want to turn it off. So it seems building Slicer against system Python is pointless but it would be much easier other than baking all the Python bindings from source when they are installed already.

Probably the reason why @myousefi2016 has been considering using system Python is to solve the Python environment mixup issues discussed in: I'm getting not a useful error when I try to start Slicer Jupyter kernel, how to debug?

I can resolve this issue possibly by modifying the cmake file to point it into a local directory probably by adding a —prefix at the end of the python install setup.py command but it would be really awkward I think. I really appreciate if there would be a better workaround for this.

I think the root cause of all issues is that wsgi package is missing from Slicer’s Python. Therefore, users must use an external Python environment to launch jupyter-notebook server. However, Slicer cannot be launched from this Python environment, due to some conflicts in site packages.

Instead of trying to solve the issue with conflicting site packages (for that we would need @jcfr’s help), I had a look at this wsgi package issue and I’ve managed to fix it!! - see https://github.com/Slicer/Slicer/pull/5190

Once this small change is integrated (probably by tomorrow), it will be possible to run Jupyter notebook server in Slicer’s Python environment, so there will be no more site package conflicts, so no need to use system Python.

Thanks @lassoan for your help! Will this PR be included in the binary preview release tomorrow? So there is no need to bake Slicer from source?

Yes, unless Jc has any objection (which is not likely).

1 Like

Thank you so much! I’m looking to use that and hopefully, my problem will be solved.