Documentation/Labs/Pip

From Slicer Wiki
Jump to: navigation, search
Home < Documentation < Labs < Pip


Starting with r25957, Pip is now available in Slicer. It can be launched as PythonSlicer -m pip ....

Installing Pip

In a nutshell, both setuptools and pip will have to be installed.

1. Download setuptools: https://bootstrap.pypa.io/ez_setup.py

2. Install setuptools:

$ Slicer ez_setup.py
Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-18.4.zip
Extracting in /tmp/tmpj3retR
Now working in /tmp/tmpj3retR/setuptools-18.4
Installing Setuptools
running install
running bdist_egg
running egg_info
writing requirements to setuptools.egg-info/requires.txt
writing setuptools.egg-info/PKG-INFO
writing top-level names to setuptools.egg-info/top_level.txt
writing dependency_links to setuptools.egg-info/dependency_links.txt
writing entry points to setuptools.egg-info/entry_points.txt
reading manifest file 'setuptools.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'setuptools.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
copying easy_install.py -> build/lib
creating build/lib/setuptools
copying setuptools/windows_support.py -> build/lib/setuptools
[...]
copying setuptools.egg-info/zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
creating dist
creating 'dist/setuptools-18.4-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing setuptools-18.4-py2.7.egg
Copying setuptools-18.4-py2.7.egg to /home/matt/bin/Slicer-4.4.0-linux-amd64/lib/Python/lib/python2.7/site-packages
Removing setuptools 5.4.1.dev0 from easy-install.pth file
Adding setuptools 18.4 to easy-install.pth file
Installing easy_install script to /home/matt/bin/Slicer-4.4.0-linux-amd64/lib/Python/bin
Installing easy_install-2.7 script to /home/matt/bin/Slicer-4.4.0-linux-amd64/lib/Python/bin

Installed /home/matt/bin/Slicer-4.4.0-linux-amd64/lib/Python/lib/python2.7/site-packages/setuptools-18.4-py2.7.egg
Processing dependencies for setuptools==18.4
Finished processing dependencies for setuptools==18.4

3. Download pip: https://bootstrap.pypa.io/get-pip.py

4. Install pip:

 $ Slicer get-pip.py
Number of registered modules: 1 
Number of instantiated modules: 1 
Number of loaded modules: 1 
Loading Slicer RC file [/home/jchris/.slicerrc.py]
Slicer RC file loaded [09/01/2013 20:41:29]
Downloading/unpacking pip
  Running setup.py egg_info for package pip
    Number of registered modules: 1
    Number of instantiated modules: 1
    Number of loaded modules: 1
    Loading Slicer RC file [/home/jchris/.slicerrc.py]
    Slicer RC file loaded [09/01/2013 20:41:38]
    warning: manifest_maker: standard file '' not found
    warning: no files found matching '*.html' under directory 'docs'
    warning: no previously-included files matching '*.txt' found under directory 'docs/_build'
    no previously-included directories found matching 'docs/_build/_sources'
Installing collected packages: pip
  Running setup.py install for pip
    Number of registered modules: 1
    Number of instantiated modules: 1
    Number of loaded modules: 1
    Loading Slicer RC file [/home/jchris/.slicerrc.py]
    Slicer RC file loaded [09/01/2013 20:41:41]
    warning: manifest_maker: standard file '' not found
    warning: no files found matching '*.html' under directory 'docs'
    warning: no previously-included files matching '*.txt' found under directory 'docs/_build'
    no previously-included directories found matching 'docs/_build/_sources'
    Installing pip script to /home/jchris/Projects/Slicer-AHM-Superbuild-Debug/python-build/bin
    Installing pip-2.6 script to /home/jchris/Projects/Slicer-AHM-Superbuild-Debug/python-build/bin
Successfully installed pip
Cleaning up...

For additional information regarding installation of pip. See http://www.pip-installer.org/en/latest/installing.html

Using Pip

1. Within the Slicer python interactor:

 ./Slicer --no-main-window --disable-cli-modules --disable-loadable-modules --disable-scripted-loadable-modules --show-python-interactor

2. Try to install a package

 import pip
 pip.main(['install', 'pygments'])