Python Virtual Environments

Instructions for creating Python virtual environments for versions 3.6 and 2.7.

  1. Load the python environment:
    – For Python 2.7:                $ module load anaconda2/4.4.0
    – For Python 3.6:                $ module load anaconda3/4.4.0
  2. Create the directory to the Python environment:
    – For Python 2.7:                $ virtualenv python2    #virtualenv creates folder in current directory that you’re in
    – For Python 3.6                 $ python3 -m venv /path/to/virtual/environment
  3. Load your environment (both 2.7 & 3.6):
$ source /path/to/virtual/environment/bin/activate

4. To leave the virtual environment.

$ deactivate
Posted in How-To-Guides, HPC