User Tools

Site Tools


venv

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
venv [2021/11/17 21:54] – created nicovenv [2022/06/15 16:37] (current) nico
Line 1: Line 1:
 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 :  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+You can create a directory for your program "mon_programme" :
  
-nicolas.greneche@magi1:~$ mkdir mon_programme +  nicolas.greneche@magi1:~$ mkdir mon_programme 
-nicolas.greneche@magi1:~$ cd mon_programme +  nicolas.greneche@magi1:~$ cd mon_programme 
-> + 
-> Ensuite tu crée un virtualenv basé sur le python de magi +Then, you can create a virtualenv based mon Magi's Python in a subdirectory called "venv" 
-> + 
-nicolas.greneche@magi1:~$ virtualenv -p /usr/bin/python3.venv +  nicolas.greneche@magi1:~$ virtualenv -p /usr/bin/python3.venv 
-> + 
-> Tu actives +You may activate the brand new environement 
-> + 
-nicolas.greneche@magi1:~$ source venv/bin/activate +  nicolas.greneche@magi1:~$ source venv/bin/activate 
-> + 
-> Comme tu peux le voir, ton nouvel interpreteur python est celui du virtualenv : +You can check that your default Python is from the virtualenv : 
-> + 
-(venv) nicolas.greneche@magi1:~/mon_programme$ which python +  (venv) nicolas.greneche@magi1:~/mon_programme$ which python 
-/nfs/homes/nicolas.greneche/mon_programme/venv/bin/python +  /nfs/homes/nicolas.greneche/mon_programme/venv/bin/python 
-> + 
-> Et enfin tu peux installer les packages de ton choix +Finally, you can install your own packages in the virtualenv 
-> + 
-(venv) nicolas.greneche@magi1:~/mon_programme$ pip install numpy+  (venv) nicolas.greneche@magi1:~/mon_programme$ pip install numpy
venv.1637182452.txt.gz · Last modified: 2021/11/17 21:54 by nico