Bonjour @rgoulancourt2,
La commande which
permet de retourner le chemin d'un exécutable localisé dans votre PATH, ce qui n'est pas le cas des bibliothèques.
Extrait du manuel de la commande which
:
which returns the pathnames of the files (or links) which would be executed in the current environment, had its arguments been given as commands in a strictly POSIX-conformant shell. It does this by searching the PATH for executable files matching the names of the arguments. It does not canonicalize path names.
La commande find
permet d'afficher les chemins d'un fichier et/ou de toutes les occurrences possibles si celui-ci se trouve dans le répertoire.
Par exemple :
ls -l /shared/home/jdoe/lib/R/R-4.4.1/library/CytoTRACE2
total 32
-rw-rw-r-- 1 jdoe jdoe 1645 Jan 24 11:57 DESCRIPTION
drwxrwxr-x 2 jdoe jdoe 4096 Jan 24 11:57 extdata/
drwxrwxr-x 2 jdoe jdoe 4096 Jan 24 11:57 help/
drwxrwxr-x 2 jdoe jdoe 4096 Jan 24 11:57 html/
-rw-rw-r-- 1 jdoe jdoe 1455 Jan 24 11:57 INDEX
drwxrwxr-x 2 jdoe jdoe 4096 Jan 24 11:57 Meta/
-rw-rw-r-- 1 jdoe jdoe 1141 Jan 24 11:57 NAMESPACE
drwxrwxr-x 2 jdoe jdoe 4096 Jan 24 11:57 R/
ls -l /shared/home/jdoe/lib/R/R-4.4.1/library/CytoTRACE2/R/
total 72
-rw-rw-r-- 1 jdoe jdoe 1058 Jan 24 11:57 CytoTRACE2
-rw-rw-r-- 1 jdoe jdoe 59133 Jan 24 11:57 CytoTRACE2.rdb
-rw-rw-r-- 1 jdoe jdoe 504 Jan 24 11:57 CytoTRACE2.rdx
echo $HOME
/shared/home/jdoe
find $HOME -name CytoTRACE2
/shared/home/jdoe/lib/R/R-4.4.1/library/CytoTRACE2
/shared/home/jdoe/lib/R/R-4.4.1/library/CytoTRACE2/R/CytoTRACE2
Les accès aux bibliothèques des langages comme Python sont gérés par d'autres variables d'environnements. Dans le cas de Python, il s'agit de la variable PYTHONPATH
. Son contenu peut être affiché dans le prompt de Python en chargeant le module sys
et en affichant le résultat de la commande sys.path
.
Par défaut, la version 3.8.10 est installée sur le cluster et, si aucun module n'est chargé, voici ce qu'affiche cette commande :
which python3 && python3 --version
/usr/bin/python3
Python 3.8.10
python3 -c "import sys ; print(sys.path)"
['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']
Si vous installez des bibliothèques dans votre Home, il faut que vous ajoutiez le chemin du répertoire contenant les fichiers des bibliothèques à cette variable (ici, des bibliothèques ont été installées dans le répertoire /shared/home/jdoe/lib/python/python-3.8.10/site-packages
):
export PYTHONPATH="/shared/home/jdoe/lib/python/python-3.8.10/site-packages;$PYTHONPATH"
python3 -c "import sys ; print(sys.path)"
['', '/shared/home/jdoe/lib/python/python-3.8.10/site-packages;', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']
ATTENTION ! Pensez à bien ajouter la variable $PYTHONPATH
à la fin, afin de conserver les chemins par défaut dans votre liste.
Ainsi, dans votre script Bash :
#!/bin/bash
## Here, your SLURM options
## ...
## Modules load
module load python/3.12
## Set your Python Environment
MY_PYTHON_LIB="/shared/home/jdoe/lib/python/python-3.12/site-packages"
export PYTHONPATH="$MY_PYTHON_LIB:$PYTHONPATH"
## Call your scripts
python3 my-python-script.py [-options]
...
Bonne journée,