Python

The scripting language Python is installed on all the interactive and computing platform at Computing Center. You can find more information about Python on the official site or by typing:

% man python
% python -h

You have the possibility to use Python in a script file. In this case, it is better to use the .py suffix. Your file should contain as the first line:

#!/usr/bin/env python

Your file should also have the “executable” Unix characteristic because Python is an interpreted language. You should not generated an binary executable in the sense of programming languages as C, C++ or Fortran.

To load Python environment:

% ccenv python <version>

To list the available versions:

% ccenv python --list

Virtual environment

You have also the option of installing locally the python packages you need without administrator rights on the servers. To do so, please follow the procedure below:

% ccenv python 3.6.7
% python -m venv --system-site-packages "my_new_env"
% source "my_new_env"/bin/activate
(my_new_env) % python -m pip install --user my_module

The first command loads the Python 3.3 environment required for using venv (available since version 3.3). The following command is used to create an “environment” from the given directory my_new_env, the directory in which the new Python packages will be installed and configured. The third command tells the system to use this environment. The last command requests Python via the pip module to install the new module my_module.

Official documentation:

You can then see the installed package:

(my_new_env) % pip list | grep my_module
(my_new_env) % pip show my_module

To exit the virtual environment, run the command:

(my_new_env) % deactivate