Documentation/Labs/Pip

From Slicer Wiki
Revision as of 17:55, 23 June 2014 by JChris.FillionR (talk | contribs) (Created page with '= Installing Pip = In a nutshell, both distribute and pip will have to be installed. 1. Download distribute: http://python-distribute.org/distribute_setup.py 2. Install dist…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Home < Documentation < Labs < Pip

Installing Pip

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

1. Download distribute: http://python-distribute.org/distribute_setup.py

2. Install distribute:

$ Slicer distribute_setup.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:23:41]
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.34.tar.gz
Extracting in /tmp/tmpW05FBr
Now working in /tmp/tmpW05FBr/distribute-0.6.34
Installing Distribute
File  "/tmp/tmpW05FBr/distribute-0.6.34/qSlicerBaseQTCore_fr.qm"  doesn't exist. 
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:24:29]
Before install bootstrap.
Scanning installed packages
No setuptools distribution found
running install
running bdist_egg
running egg_info
writing distribute.egg-info/PKG-INFO
writing top-level names to distribute.egg-info/top_level.txt
[...]
Installed /home/jchris/Projects/Slicer-AHM-Superbuild-Debug/python-build/lib/python2.6/site-packages/distribute-0.6.34-py2.6.egg
Processing dependencies for distribute==0.6.34
Finished processing dependencies for distribute==0.6.34
After install bootstrap.
Creating /home/jchris/Projects/Slicer-AHM-Superbuild-Debug/python-build/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info
Creating /home/jchris/Projects/Slicer-AHM-Superbuild-Debug/python-build/lib/python2.6/site-packages/setuptools.pth

3. Download pip: https://raw.github.com/pypa/pip/master/contrib/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. Define the function install_distributions

def install_distributions(distributions):
  """
  Copied from http://threebean.org/blog/2011/06/06/installing-from-pip-inside-python-or-a-simple-pip-api/
  """
  import pip.commands.install
  command = pip.commands.install.InstallCommand()
  opts, args = command.parser.parse_args()
  # TBD, why do we have to run the next part here twice before actual install
  requirement_set = command.run(opts, distributions)
  requirement_set = command.run(opts, distributions)
  requirement_set.install(opts)

3. Try to install a package

install_distributions(["Markdown"])