Difference between revisions of "Documentation/Labs/Pip"

From Slicer Wiki
Jump to: navigation, search
Line 13: Line 13:
  
 
<pre>
 
<pre>
Number of registered modules: 1
+
Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-18.4.zip
Number of instantiated modules: 1
+
Extracting in /tmp/tmpj3retR
Number of loaded modules: 1
+
Now working in /tmp/tmpj3retR/setuptools-18.4
Loading Slicer RC file [/home/jchris/.slicerrc.py]
+
Installing Setuptools
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 install
 
running bdist_egg
 
running bdist_egg
 
running egg_info
 
running egg_info
writing distribute.egg-info/PKG-INFO
+
writing requirements to setuptools.egg-info/requires.txt
writing top-level names to distribute.egg-info/top_level.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
 
[...]
 
[...]
Installed /home/jchris/Projects/Slicer-AHM-Superbuild-Debug/python-build/lib/python2.6/site-packages/distribute-0.6.34-py2.6.egg
+
copying setuptools.egg-info/zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
Processing dependencies for distribute==0.6.34
+
creating dist
Finished processing dependencies for distribute==0.6.34
+
creating 'dist/setuptools-18.4-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
After install bootstrap.
+
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Creating /home/jchris/Projects/Slicer-AHM-Superbuild-Debug/python-build/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info
+
Processing setuptools-18.4-py2.7.egg
Creating /home/jchris/Projects/Slicer-AHM-Superbuild-Debug/python-build/lib/python2.6/site-packages/setuptools.pth
+
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
 
</pre>
 
</pre>
  

Revision as of 21:38, 21 October 2015

Home < Documentation < Labs < 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 distribute:

$ 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://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"])