Python on Workstations FAQ — RCG Handbook

Python on Workstations FAQ

Installing your own Python packages with pip

$ module load LANG/PYTHON/2.7.13-SYSTEM
[run `module avail` to see other versions]

$ pip install --user modulename   # Python 2.x
$ pip3 install --user modulename  # Python 3.x

The commands above will install a Python module in your home directory without the need for administrator privileges.

Warning

Please don’t upgrade pip when it asks. :-) It will break if you do. See below if you have a broken copy of pip.

Installing your own Python packages with Anaconda

If environment modules don’t meet your needs, install Anaconda (no sudo privileges required) and use conda install to manage your own Python environment.

I need a newer version of Python installed

Newer versions of Python are available as environment modules.

$ module avail   [to see all the Python versions available]
$ module load LANG/PYTHON/3.5.2-SYSTEM
$ which python3

[now Python 3.5.2 will be loaded when you run 'python3']

$ module purge
[back to system python]

Power users should check out Quick Tips for Using Environment Modules.

Some users may prefer using Anaconda to manage different versions of Python and Python packages.

I upgraded pip and now it’s broken

Traceback (most recent call last):
   ...
   from pip import main
ImportError: cannot import name main

If pip refuses to run and gives you the above error, Don’t Panic(tm). Just delete your local copy of pip. Depending on which Python version you were using when you upgraded pip, you’ll need to clear out some or all of these paths:

~/.local/lib/python2.7/site-packages/pip*
~/.local/lib/python3.5/site-packages/pip*
~/.local/lib/python3.6/site-packages/pip*

Pip should run normally after you delete these files. Contact research-support@sfu.ca if you continue to have trouble.