Installing python virtualenv: Difference between revisions

From IThelp
(Added the page. Translated from "Installere python virtualenv".)
 
m (Added so empty lines to fix the format.)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[no: Installere python virtualenv]]
== Virtualenv ==
== Virtualenv ==


Virtualenv creates an isolated space for a project, together with a copy all you need to run a python program. The virtualenv tool can f.i. be used to solve problems that arise from having multiple python projects with different/incompatible demands to the setup of a given system.
Virtualenv creates an isolated space for a project, together with a copy of all you need to run a python program. The virtualenv tool can f.i. be used to solve problems that arise from having multiple python projects with different/incompatible demands to the setup of a given system.




Line 8: Line 9:
[user@hostname ~]$ sudo apt-get install python-virtualenv
[user@hostname ~]$ sudo apt-get install python-virtualenv
</pre>
</pre>


Creating an isolated space for a given project, with pip included:
Creating an isolated space for a given project, with pip included:
Line 17: Line 19:
[user@hostname myproject_env]$ source bin/activate
[user@hostname myproject_env]$ source bin/activate
</pre>
</pre>


Adding python packages to the prosject:
Adding python packages to the prosject:
Line 22: Line 25:
[user@hostname myproject_env]$ pip install pythonpackage
[user@hostname myproject_env]$ pip install pythonpackage
</pre>
</pre>
* The packages will be stored in myproject_env/. They are only available for the given project.
* The packages will be stored in myproject_env/. They are only available to the given project.
 


To complete/close work on a project:
To complete/close work on a project:

Latest revision as of 14:07, 25 January 2018

Virtualenv

Virtualenv creates an isolated space for a project, together with a copy of all you need to run a python program. The virtualenv tool can f.i. be used to solve problems that arise from having multiple python projects with different/incompatible demands to the setup of a given system.


Installing virtualenv:

[user@hostname ~]$ sudo apt-get install python-virtualenv


Creating an isolated space for a given project, with pip included:

[user@hostname ~]$ cd path/to/all/my/projects
[user@hostname allmyprojects]$ virtualenv myproject_env
[user@hostname allmyprojects]$ cd myproject_env
[user@hostname myproject_env]$ source bin/activate


Adding python packages to the prosject:

[user@hostname myproject_env]$ pip install pythonpackage
  • The packages will be stored in myproject_env/. They are only available to the given project.


To complete/close work on a project:

(myproject_env)[user@hostname myproject_env]$ deactivate