The aim of virtualenv is to provide your own instance of Python as maintaining different versions of packages is really tricky. This tutorial shows how to have a tailored Python environement for your program :
You can create a directory for your program “mon_programme” :
nicolas.greneche@magi1:~$ mkdir mon_programme nicolas.greneche@magi1:~$ cd mon_programme
Then, you can create a virtualenv based mon Magi's Python in a subdirectory called “venv” :
nicolas.greneche@magi1:~$ virtualenv -p /usr/bin/python3.9 venv
You may activate the brand new environement :
nicolas.greneche@magi1:~$ source venv/bin/activate
You can check that your default Python is from the virtualenv :
(venv) nicolas.greneche@magi1:~/mon_programme$ which python /nfs/homes/nicolas.greneche/mon_programme/venv/bin/python
Finally, you can install your own packages in the virtualenv :
(venv) nicolas.greneche@magi1:~/mon_programme$ pip install numpy