HOWTO: Add python packages using the conda package manager

While our python installations come with many popular packages installed, you may come upon a case where you need an addiditonal package that is not installed.  If the specific package you are looking for is available from Anaconda.org (formerlly binstar.org) you can easily install it and required dependencies by using the Conda package manager.

To be able to install a package using the conda package manager:

  • You must use a Anaconda distribution of python:
    • On Oakley the following modules:
      • python/2.7.8, python/3.4.2
    • On Ruby:
      • python/2.7.8, python/3.4.2
  • Package must be available through Anaconda.org

 

Procedure

We will install the yt package to a local directory in this example.

Load proper python module

module load python/2.7.8

Clone python installation to local directory

conda create -n local --clone="$PYTHON_HOME"

Activate clone environment

source activate local

Install package

conda install yt
  • Replace yt with the name of the package you want to install, as listed by anaconda.org.
If there are errors on this step you will need to resolve them before continuing.

Test python package

Now we will test our installed python package by loading it in python and checking its location to ensure we are using the correct version.

python -c "import yt;print yt.__file__"

Output:

/nfs/12/osu8968/.conda/envs/local/lib/python2.7/site-packages/yt/__init__.py
  • Replace both instances of yt with the name of the package you installed.
Remember, you will need to load the proper version of python before you go to use your newlly installed package.  Packages are only installed to one version of python.