# Slicer-Python Packages Use and Install

**URL:** <https://discourse.slicer.org/t/slicer-python-packages-use-and-install/984>\
**Category:** Support\
**Created:** [August 31, 2017, 9:27pm UTC](https://discourse.slicer.org/t/slicer-python-packages-use-and-install/984 "2017-08-31T21:27:14Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [August 31, 2017, 9:46pm UTC](https://discourse.slicer.org/t/slicer-python-packages-use-and-install/984/2 "2017-08-31T21:46:06Z")

</div>

> [@ssyip](#):
>
> 1. If I already have Python 2.7 and all packages I want installed on my computer, can I add path in Slicer so it knows where to find those packages?
> 
> 2. I tried to copy and paste all the installed packages into the “Slicer 4.6.2\lib\Python\Lib\site-packages” folder, but Slicer ended up not running at all.

Since Slicer bundles its own _python_, it is generally **NOT** possible to simply copy python packages (especially the one including binaries) from your own `site-packages` into the one of Slicer.

That said, depending on the platform there is way around it.

First, I suggest you download the latest nightly build of Slicer.

There are a lot of improvement regarding the python infrastructure. It for example includes an updated `setuptools` as well as `pip`.

Second, on linux (and most likely macOS), it is indeed **possible to pip install official packages** (even the including binaries like `scipy`, `tensorflow`, …).

On windows, it will currently work only for _pure_ python wheels because the official package for python 2.7 are built with a compiler than the one used for the official wheels. Note that this will change as soon as we standardize on Visual Studio 2015 and switch to python \>= 3.5.

> [@ssyip](#):
>
> 1. Does anyone know how to install packages through the python interactor? I tried to install pip, but keep getting errors.

As mentioned above, the good news is that `pip` is available in Slicer.

#### build tree

From a build tree, you can do:

```bash
./Slicer --launch ../python-install/bin/pip install scipy

```

or something like this on windows (only for pure python wheels)

```bash
Slicer.exe --launch ..\python-install\bin\pip.exe install name-of-pure-python-wheel

```

#### install tree or python interactor

Since we do not (yet) package the `pip` executable, you will have to use a different approach.

##### from the terminal

```bash
./Slicer --launch ./bin/python-real -c "import pip; pip.main(['install', 'scipy'])"

```

or something like this on windows

```bash
Slicer.exe --launch bin\python-real.exe -c "import pip; pip.main(['install', 'scipy'])"

```

##### from python interactor

```python
import pip
pip.main(['install', 'scipy'])

```

---

_[View the full topic](https://discourse.slicer.org/t/slicer-python-packages-use-and-install/984)._
