# How to import python libraries installed with --user option

**URL:** <https://discourse.slicer.org/t/how-to-import-python-libraries-installed-with-user-option/10112>\
**Category:** Support\
**Created:** [February 4, 2020, 9:16pm UTC](https://discourse.slicer.org/t/how-to-import-python-libraries-installed-with-user-option/10112 "2020-02-04T21:16:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/83011_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [February 4, 2020, 9:16pm UTC](https://discourse.slicer.org/t/how-to-import-python-libraries-installed-with-user-option/10112/1 "2020-02-04T21:16:42Z")

</div>

on a shared linux system, if I install pip\_install a python package I get this error

> ```
> >>> pip_install('scipy')
> Collecting scipy
> Using cached https://files.pythonhosted.org/packages/dc/29/162476fd44203116e7980cfbd9352eef9db37c49445d1fec35509022f6aa/scipy-1.4.1-cp36-cp36m-manylinux1_x86_64.whl
> Requirement already satisfied: numpy>=1.13.3 in /data/home/apps/Slicer-4.11.0-2020-01-30-linux-amd64/lib/Python/lib/python3.6/site-packages (from scipy) (1.17.3)
> Installing collected packages: scipy
> ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/home/apps/Slicer-4.11.0-2020-01-30-linux-amd64/lib/Python/lib/python3.6/site-packages/scipy'
> Consider using the `--user` option or check the permissions.
> 
> ```

When I use the --user option, scipy is installed under **~/.local/lib/python3.6/site-packages** , but I can’t import it into Slicer.

> import scipy  
> Traceback (most recent call last):  
> File “”, line 1, in   
> ModuleNotFoundError: No module named ‘scipy’

Is the only solution to install slicer into a user-writable folder?

---

<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:** [February 4, 2020, 10:21pm UTC](https://discourse.slicer.org/t/how-to-import-python-libraries-installed-with-user-option/10112/2 "2020-02-04T22:21:24Z")

</div>

Yes, if you want to install a package in the application tree you need to be able to write there.

Or you could try [appending to `sys.path`](https://stackoverflow.com/questions/3108285/in-python-script-how-do-i-set-pythonpath) before importing.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [February 4, 2020, 11:47pm UTC](https://discourse.slicer.org/t/how-to-import-python-libraries-installed-with-user-option/10112/3 "2020-02-04T23:47:33Z")

</div>

If specifically about `scipy` I have a Slicer [PR #1254](https://github.com/Slicer/Slicer/pull/1254#) to include Scipy in the standard build. It is a WIP as I stopped working on it after having some issues with it quietly failing due to some likely parallel build problem. Updates to this PR would be welcomed.
