Users may want to install python packages that are frequently used by their groups, in a common location to the user or group.

The simple way installs under .local in your home directory (substitute package-name for what you want):

pip install --user package-name

or, if you download the package and it has a setup.py:

python setup.py --user

If you’d like to install the package to a custom directory, here is a more detailed example:

  1. Create a local directory:
    mkdir -p $HOME/my-python-modules/lib/python2.7/site-packages
  2. Download the package source, preferably to the scratch directory. This example will install “pyquante”. This package can be downloaded from “https://sourceforge.net/projects/pyquante”. You may be able to use wget or svn, etc, to download your package.
  3. cd $HOME/scratch
  4. tar zxvpf PyQuante-1.6.5.tar.gz

    This will extract all the files into /scratch/users/$USER/PyQuante-1.6.5

  5. cd PyQuante-1.6.5
  6. Type “ls”. You should see a file “setup.py”
  7. Make sure you load the version of python you want to use, for example: module load python
  8. Check: type “ml” You should see Python/2.7.10
  9. Install it on your local directory:
    python setup.py install --prefix=$HOME/my-python-modules 

    Note: You may want to check that you are using the proper compiler.

  10. Check:
    ls $HOME/my-python-modules/lib/python2.7/site-packages
  11. Utilization. You need to either do this manually or create a module
  12. Manually:
    export PATH=$HOME/my-python-modules/bin:$PATH (if necessary)
     export PYTHONPATH=$HOME/my-pyhton-modules/lib/python2.7/site-packages:$PYTHONPATH
  13. Create a module.
    "mkdir -p $HOME/privatemodules/PyQuante"
  14. Create a file called “1.6.5.lua” in the above directory with the following contents:  (NOTE:  1.6.5 is the version number in this case for PyQuante)
    whatis([[local module for PyQuante ]])
    
    prepend_path{"PATH","$HOME/my-python-modules/bin",delim=":",priority="0"}
    append_path{"PYTHONPATH", "/$HOME/my-python-modules/lib/python2.7/site-packages", delim=":",priority="0"}
    
  15. To load it: “module load use.own”
    module load PyQuante
  16. Check. echo $PYTHONPATH

 

 

That is it!