Python 3

Lien pour mise en place de l’environnement python !

Lancement de python3

  • Pour utiliser Python, tapez la ligne de commande « python3 ».
$ python3
Python 3.9.21 (main, Aug 19 2025, 00:00:00)
[GCC 11.5.0 20240719 (Red Hat 11.5.0-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
  • Vous pouvez utiliser une version plus récente de python3 en chargeant un module.
$ ml python/3.13.7 
$ python3
Python 3.13.7 (main, Sep 9 2025, 10:17:02) [GCC 11.5.0 20240719 (Red Hat 11.5.0-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.

Chargement d’une librairie

  • Le chargement d’une librairie se fait avec la commande import
python3
Python 3.9.21 (main, Aug 19 2025, 00:00:00)
[GCC 11.5.0 20240719 (Red Hat 11.5.0-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
  • Une librairie peut être installée dans une version de Python mais pas dans une autre.
$ ml python/3.11.7 
$ python3
Python 3.11.7 (main, Jan 9 2026, 13:34:55) [GCC 15.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas'

Dans cet exemple, la librairie pandas est bien installée dans la version 3.9.21 mais pas dans la version 3.11.7.

Installation d’une librairie

En tant de que simple utilisateur, possibilité d’installer une librairie python.

Exemple avec pandas

$ ml python/3.11.7
$ pip3 install --no-cache-dir --upgrade --user pandas
Collecting pandas
  Downloading pandas-3.0.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.metadata (79 kB)
Collecting numpy>=1.26.0 (from pandas)
  Downloading numpy-2.4.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.metadata (6.6 kB)
Collecting python-dateutil>=2.8.2 (from pandas)
  Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)
Collecting six>=1.5 (from python-dateutil>=2.8.2->pandas)
  Downloading six-1.17.0-py2.py3-none-any.whl.metadata (1.7 kB)
Downloading pandas-3.0.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (11.3 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11.3/11.3 MB 371.6 kB/s  0:00:29
Downloading numpy-2.4.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.9 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 16.9/16.9 MB 377.3 kB/s  0:00:44
Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
Downloading six-1.17.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: six, numpy, python-dateutil, pandas
Successfully installed numpy-2.4.2 pandas-3.0.1 python-dateutil-2.9.0.post0 six-1.17.0
$ python3
Python 3.11.7 (main, Jan  9 2026, 13:34:55) [GCC 15.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas

Remarque(s) :

  • Parfois, l’installation peut échouer. Vérifier que la librairie est bien compatible avec la version de Python.
  • Les librairies sont placés dans votre répertoire .local.