Skip to content

Using Python Packages

userz edited this page Aug 22, 2017 · 1 revision

This guide will show you how to setup your HPC account so that you can access Python packages installed by AidData and also install and access your own Python packages. Make sure a Python module is loaded on your HPC account before attempting to run Python.

note: if you are using a version of Python other than 2.7, you will need to adjust the example paths shown below

Central Repository

AidData maintains numerous packages used by the Geo Framework and other applications. Other users are free to utilize these packages

The packages are locatedin:

/sciclone/aiddata10/REU/py_libs/lib/python2.7/site-packages

Once you include this path in your Python path (see Options below) you will be able to access any Python packages available in the AidData central repository normally by using import <package-name> in Python

The packages available from the AidData central repository can be seen using ls /sciclone/aiddata10/REU/py_libs/lib/python2.7/site-packages while logged in to sciclone. Note: additional packages not listed here may have been installed globally on sciclone. Pip is installed on sciclone, so you can use pip show to see all packages available based on your active Python path.

Installing Packages

When packages are not installed globally on sciclone or in the AidData repository, you can often install packages locally on your sciclone account using Pip.

  1. make a new folder called py_libs in your home directory >> eg, mkdir ~/py_libs
  2. install a package to your local py_libs folder >> pip install --no-use-wheel --ignore-installed --install-option="--prefix=~/py_libs" <package-name>

Dependencies for some packages may require root access to install. You can contact the HPC staff to request the package in these instances.

Option 1: Permanent Path

  1. Open the .cshrc file in your home directory: nano ~/.cshrc
  2. Add the following line of code at the end of the file:
setenv PYTHONPATH ${PYTHONPATH}:/sciclone/aiddata10/REU/py_libs/lib/python2.7/site-packages

then log out and back in or use source ~/.cshrc

Option 2: Temporary Path

Inside any Python script for which you need access to Python packages installed by AidData add the following lines of code:

  1. import sys
  2. sys.path.append("/sciclone/aiddata10/REU/py_libs/lib/python2.7/site-packages")