You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/dev/virtualenvs.rst
+27-14Lines changed: 27 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,18 @@
1
1
Virtual Environments
2
2
====================
3
3
4
-
A Virtual Environment, put simply, is an isolated working copy of Python which allows you to work on a specific project without worry of affecting other projects.
5
-
6
-
For example, you can work on a project which requires Django 1.3 at the same time with a project which requires Django 1.0.
4
+
A Virtual Environment, put simply, is an isolated working copy of Python which
5
+
allows you to work on a specific project without worry of affecting other
6
+
projects.
7
7
8
+
For example, you can work on a project which requires Django 1.3 while also
9
+
maintaining a project which requires Django 1.0.
8
10
9
11
virtualenv
10
12
----------
11
13
12
-
`virtualenv <http://pypi.python.org/pypi/virtualenv>`_ is a tool to create isolated Python environments.
14
+
`virtualenv <http://pypi.python.org/pypi/virtualenv>`_ is a tool to create
15
+
isolated Python environments.
13
16
14
17
Install it via pip::
15
18
@@ -22,28 +25,34 @@ Basic Usage
22
25
23
26
$ virtualenv ENVIRONMENT_NAME
24
27
25
-
This creates a copy of Python in whichever directory you ran the command in, placing it in a folder named ``ENVIRONMENT_NAME``.
28
+
This creates a copy of Python in whichever directory you ran the command in,
29
+
placing it in a folder named ``ENVIRONMENT_NAME``.
26
30
27
31
2. To begin using the virtual environment, it needs to be activated::
28
32
29
33
$ source ENVIRONMENT_NAME/bin/activate
30
34
31
-
You can then begin installing any new modules without affecting the system default Python or other virtual environments.
35
+
You can then begin installing any new modules without affecting the system
36
+
default Python or other virtual environments.
32
37
33
-
3. If you are done working in the virtual environment for the moment, you can deactivate it::
38
+
3. If you are done working in the virtual environment for the moment, you can
39
+
deactivate it::
34
40
35
41
$ deactivate
36
42
37
-
This puts you back to the system's default Python interpreter with all its installed libraries.
43
+
This puts you back to the system's default Python interpreter with all its
44
+
installed libraries.
38
45
39
46
To delete a virtual environment, just delete its folder.
40
47
41
48
virtualenvwrapper
42
49
-----------------
43
50
44
-
`virtualenvwrapper <http://www.doughellmann.com/projects/virtualenvwrapper/>`_ provides a set of commands which makes working with virtual environments much more pleasant. It also places all your virtual environments into one place.
provides a set of commands which makes working with virtual environments much
53
+
more pleasant. It also places all your virtual environments into one place.
45
54
46
-
To install (make sure virtualenv is already installed)::
55
+
To install (make sure **virtualenv** is already installed)::
47
56
48
57
$ pip install virtualenvwrapper
49
58
$ export WORKON_HOME=~/Envs
@@ -64,8 +73,11 @@ This creates the ``ENVIRONMENT_NAME`` folder inside ``~/Envs``.
64
73
65
74
$ workon ENVIRONMENT_NAME
66
75
67
-
**virtualenvwrapper** provides tab-completion on environment names. It really helps when you have a lot of environments and have trouble remembering their names.
68
-
``workon`` also deactivates whatever environment you are currently in, so you can quickly switch between environments.
76
+
**virtualenvwrapper** provides tab-completion on environment names. It really
77
+
helps when you have a lot of environments and have trouble remembering their
78
+
names.
79
+
``workon`` also deactivates whatever environment you are currently in, so you
80
+
can quickly switch between environments.
69
81
70
82
3. Deactivating is still the same::
71
83
@@ -81,12 +93,13 @@ Other nifty commands include:
81
93
List all of the environments.
82
94
83
95
``cdvirtualenv``
84
-
Navigate into the directory of the currently activated virtual environment, so you can browse its ``site-packages``, for example.
96
+
Navigate into the directory of the currently activated virtual environment,
97
+
so you can browse its ``site-packages``, for example.
85
98
86
99
``cdsitepackages``
87
100
Like the above, but directly into ``site-packages`` directory.
88
101
89
102
``lssitepackages``
90
103
Shows contents of ``site-packages`` directory.
91
104
92
-
Full list of commands can be found `here <http://www.doughellmann.com/docs/virtualenvwrapper/command_ref.html#managing-environments>`_.
105
+
A full list of commands can be found `here <http://www.doughellmann.com/docs/virtualenvwrapper/command_ref.html#managing-environments>`_.
0 commit comments