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

**URL:** <https://discourse.slicer.org/t/simpleitk-tries-to-write-python-wrapped-files-into-a-default-folder-that-needs-root-privileges/13536>\
**Category:** Support\
**Created:** [September 18, 2020, 7:01am UTC](https://discourse.slicer.org/t/simpleitk-tries-to-write-python-wrapped-files-into-a-default-folder-that-needs-root-privileges/13536 "2020-09-18T07:01:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![myousefi2016](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/myousefi2016/32/7602_2.png) [@myousefi2016](https://discourse.slicer.org/u/myousefi2016)\
**Post date:** [September 18, 2020, 7:01am UTC](https://discourse.slicer.org/t/simpleitk-tries-to-write-python-wrapped-files-into-a-default-folder-that-needs-root-privileges/13536/1 "2020-09-18T07:01:34Z")

</div>

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

```auto
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:

```auto
[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?

---

<div class="post-metadata">

**Author:** ![Alex\_Vergara](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/alex_vergara/32/15205_2.png) [@Alex\_Vergara](https://discourse.slicer.org/u/Alex_Vergara)\
**Post date:** [September 18, 2020, 7:10am UTC](https://discourse.slicer.org/t/simpleitk-tries-to-write-python-wrapped-files-into-a-default-folder-that-needs-root-privileges/13536/2 "2020-09-18T07:10:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 18, 2020, 12:02pm UTC](https://discourse.slicer.org/t/simpleitk-tries-to-write-python-wrapped-files-into-a-default-folder-that-needs-root-privileges/13536/3 "2020-09-18T12:02:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![myousefi2016](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/myousefi2016/32/7602_2.png) [@myousefi2016](https://discourse.slicer.org/u/myousefi2016)\
**Post date:** [September 18, 2020, 12:06pm UTC](https://discourse.slicer.org/t/simpleitk-tries-to-write-python-wrapped-files-into-a-default-folder-that-needs-root-privileges/13536/4 "2020-09-18T12:06:03Z")

</div>

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.

---

<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 18, 2020, 12:22pm UTC](https://discourse.slicer.org/t/simpleitk-tries-to-write-python-wrapped-files-into-a-default-folder-that-needs-root-privileges/13536/5 "2020-09-18T12:22:19Z")

</div>

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?](https://discourse.slicer.org/t/im-getting-not-a-useful-error-when-i-try-to-start-slicer-jupyter-kernel-how-to-debug/13530/7)

---

<div class="post-metadata">

**Author:** ![myousefi2016](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/myousefi2016/32/7602_2.png) [@myousefi2016](https://discourse.slicer.org/u/myousefi2016)\
**Post date:** [September 18, 2020, 12:55pm UTC](https://discourse.slicer.org/t/simpleitk-tries-to-write-python-wrapped-files-into-a-default-folder-that-needs-root-privileges/13536/6 "2020-09-18T12:55:43Z")

</div>

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.

---

<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 18, 2020, 2:27pm UTC](https://discourse.slicer.org/t/simpleitk-tries-to-write-python-wrapped-files-into-a-default-folder-that-needs-root-privileges/13536/7 "2020-09-18T14:27:30Z")

</div>

I think the root cause of all issues is that [wsgi package is missing from Slicer’s Python](https://github.com/Slicer/SlicerJupyter/issues/39). 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](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.

---

<div class="post-metadata">

**Author:** ![myousefi2016](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/myousefi2016/32/7602_2.png) [@myousefi2016](https://discourse.slicer.org/u/myousefi2016)\
**Post date:** [September 18, 2020, 2:30pm UTC](https://discourse.slicer.org/t/simpleitk-tries-to-write-python-wrapped-files-into-a-default-folder-that-needs-root-privileges/13536/8 "2020-09-18T14:30:39Z")

</div>

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?

---

<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 18, 2020, 2:32pm UTC](https://discourse.slicer.org/t/simpleitk-tries-to-write-python-wrapped-files-into-a-default-folder-that-needs-root-privileges/13536/9 "2020-09-18T14:32:31Z")

</div>

> [@myousefi2016](#):
>
> Thanks @lassoan for your help! Will this PR be included in the binary preview release tomorrow?

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

---

<div class="post-metadata">

**Author:** ![myousefi2016](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/myousefi2016/32/7602_2.png) [@myousefi2016](https://discourse.slicer.org/u/myousefi2016)\
**Post date:** [September 18, 2020, 2:35pm UTC](https://discourse.slicer.org/t/simpleitk-tries-to-write-python-wrapped-files-into-a-default-folder-that-needs-root-privileges/13536/10 "2020-09-18T14:35:14Z")

</div>

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