Skip to content

6. Python

Available Python versions

Python is available on the ABCI System.

To show available Python versions with using module command:

$ module avail python

-------------------------------- /apps/modules/modulefiles/devtools --------------------------------
python/2.7/2.7.15 python/3.4/3.4.8  python/3.5/3.5.5  python/3.6/3.6.5

To set up one of available versions with using module command:

Example) Python 2.7.15:

$ module load python/2.7/2.7.15
$ python --version
Python 2.7.15

Example) Python 3.6.5:

$ module load python/3.6/3.6.5
$ python --version
Python 3.6.5

Note

Users can install any python distributions (c.f., pyenv, conda) into their own home or group area. Please kindly note that such distributions are not eligible for the ABCI System support.

Python Virtual Environments

The ABCI System does not allow users to modify the system environment. Instead, it supports users to create Python virtual environments and install necessary modules into them.

On ABCI, virtualenv and venv modules provide support for creating lightweight “virtual environments” with their own site directories, optionally isolated from system site directories. Each virtual environment has its own Python binary (which matches the version of the binary that was used to create this environment) and can have its own independent set of installed Python packages in its site directories.

Creating virtual environments, we use virtualenv for Python 2 and venv for Python 3, respectively.

virtualenv

Below are examples of executing virtualenv:

Example) Creation of a virtual environment

[username@es1 ~]$ module load python/2.7/2.7.15
[username@es1 ~]$ virtualenv env1
New python executable in /home/username/env1/bin/python2.7
Also creating executable in /home/username/env1/bin/python
Installing setuptools, pip, wheel...done.

Example) Activating a virtual environment

[username@es1 ~]$ source env1/bin/activate
(env1) [username@es1 ~]$
(env1) [username@es1 ~]$ which python
~/env1/bin/python
(env1) [username@es1 ~]$ which pip
~/env1/bin/pip

Example) Installing numpy to a virtual environment

(env1) [username@es1 ~]$ pip install numpy

Example) Deactivating a virtual environment

(env1) [username@es1 ~]$ deactivate
[username@es1 ~]$

venv

Below are examples of executing venv:

Example) Creation of a virtual environment

[username@es1 ~]$ module load python/3.6/3.6.5
[username@es1 ~]$ python3 -m venv work

Example) Activating a virtual environment

[username@es1 ~]$ source work/bin/activate
(work) [username@es1 ~]$ which python3
/fs3/home/username/work/bin/python3
(work) [username@es1 ~]$ which pip3
/fs3/home/username/work/bin/pip3

Example) Installing numpy to a virtual environment

(work) [username@es1 ~]$ pip3 install numpy

Example) Deactivating a virtual environment

(work) [username@es1 ~]$ deactivate
[username@es1 ~]$

pip

pip in the package management system for Python. You can use pip to install packages from the Python Pakcage Index (PyPI), a repository of Python software.

$ pip <sub-command> [options]
sub command description
install package install package
update package update package
uninstall package remove package
search package search package
list list installed packages