Python on Workstations FAQs

Summary

Learn how to install your own Python packages on research workstations.

Body

POPULAR PYTHON PACKAGES

Common packages like SciPyNumPymatplotlib and IPython are already installed in our Python environment modules.

$ module avail   [to see all the Python versions available]
$ module load LANG/PYTHON/2.7.13-SYSTEM
$ pip list       [to see what's inside LANG/PYTHON/2.7.13]
...
ipython (0.13.2)
numpy (1.4.1)
pilkit (1.1.12)
scikit-learn (0.15.2)
scipy (0.7.2)
sckdump (2.0.5)

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.

HOW CAN I USE PYCHARM WITH LANG/PYTHON/X?

Please see our PyCharm and Environment Modules page.

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.

Details

Details

Article ID: 3923
Created
Wed 7/6/22 9:36 PM
Modified
Wed 7/6/22 9:36 PM