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.
Note
Different releases are available at CC-IN2P3. Please follow the software loader syntax to list and activate the required release.
Please also consider the tips on custom-installations.
To go even further, you can refer to the documents used during the trainings provided by the CC-IN2P3.
Virtual environment
You have also the option of installing locally the python packages you need without administrator rights on the servers.
To do so you will need to load a release following Python 3.3 (venv
is only available from version 3.3) and follow the procedure below:
% python -m venv --system-site-packages <environment name>
% source <environment name>/bin/activate
(<environment name>) % python -m pip install --user <new module>
or by specfiying the path:
(<environment name>) % python -m pip install --prefix /<path>/<new module>
The first command is used to create an “environment” from the given directory
<environment name>
, the directory in which the new Python packages will be installed and configured.The following command tells the system to use this environment.
The last command requests Python via the
pip
module to install the new module<new module>
Official documentation:
You can then see the installed package:
(<environment name>) % pip list | grep <new module>
(<environment name>) % pip show <new module>
To exit the virtual environment, run the command:
(<environment name>) % deactivate