1
1
Virtual Environments
2
2
====================
3
3
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
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
6
projects.
7
7
8
- For example, you can work on a project which requires Django 1.3 while also
8
+ For example, you can work on a project which requires Django 1.3 while also
9
9
maintaining a project which requires Django 1.0.
10
10
11
11
virtualenv
12
12
----------
13
13
14
- `virtualenv <http://pypi.python.org/pypi/virtualenv >`_ is a tool to create
14
+ `virtualenv <http://pypi.python.org/pypi/virtualenv >`_ is a tool to create
15
15
isolated Python environments.
16
16
17
17
Install it via pip:
@@ -29,7 +29,7 @@ Basic Usage
29
29
30
30
$ virtualenv venv
31
31
32
- This creates a copy of Python in whichever directory you ran the command in,
32
+ This creates a copy of Python in whichever directory you ran the command in,
33
33
placing it in a folder named ``venv ``.
34
34
35
35
2. To begin using the virtual environment, it needs to be activated:
@@ -38,30 +38,30 @@ placing it in a folder named ``venv``.
38
38
39
39
$ source venv/bin/activate
40
40
41
- You can then begin installing any new modules without affecting the system
41
+ You can then begin installing any new modules without affecting the system
42
42
default Python or other virtual environments.
43
43
44
- 3. If you are done working in the virtual environment for the moment, you can
44
+ 3. If you are done working in the virtual environment for the moment, you can
45
45
deactivate it:
46
46
47
47
.. code-block :: console
48
48
49
49
$ deactivate
50
50
51
- This puts you back to the system's default Python interpreter with all its
51
+ This puts you back to the system's default Python interpreter with all its
52
52
installed libraries.
53
53
54
54
To delete a virtual environment, just delete its folder.
55
55
56
- After a while, though, you might end up with a lot of virtual environments
57
- littered across your system, and its possible you'll forget their names or
58
- where they were placed.
56
+ After a while, though, you might end up with a lot of virtual environments
57
+ littered across your system, and its possible you'll forget their names or
58
+ where they were placed.
59
59
60
60
virtualenvwrapper
61
61
-----------------
62
62
63
- `virtualenvwrapper <http://www.doughellmann.com/projects/virtualenvwrapper/ >`_
64
- provides a set of commands which makes working with virtual environments much
63
+ `virtualenvwrapper <http://www.doughellmann.com/projects/virtualenvwrapper/ >`_
64
+ provides a set of commands which makes working with virtual environments much
65
65
more pleasant. It also places all your virtual environments in one place.
66
66
67
67
To install (make sure **virtualenv ** is already installed):
@@ -74,6 +74,17 @@ To install (make sure **virtualenv** is already installed):
74
74
75
75
(`Full virtualenvwrapper install instructions <http://www.doughellmann.com/docs/virtualenvwrapper/#introduction >`_.)
76
76
77
+ For Windows, you can use the `virtualenvwrapper-powershell <https://bitbucket.org/guillermooo/virtualenvwrapper-powershell >`_ clone.
78
+
79
+ To install (make sure **virtualenv ** is already installed):
80
+
81
+ .. code-block :: console
82
+
83
+ PS> pip install virtualenvwrapper-powershell
84
+ PS> $env:WORKON_HOME="~/Envs"
85
+ PS> mkdir $env:WORKON_HOME
86
+ PS> import-module virtualenvwrapper
87
+
77
88
Basic Usage
78
89
~~~~~~~~~~~
79
90
@@ -83,18 +94,18 @@ Basic Usage
83
94
84
95
$ mkvirtualenv venv
85
96
86
- This creates the ``venv `` folder inside ``~/Envs ``.
97
+ This creates the ``venv `` folder inside ``~/Envs ``.
87
98
88
99
2. Work on a virtual environment:
89
100
90
101
.. code-block :: console
91
102
92
103
$ workon venv
93
104
94
- **virtualenvwrapper ** provides tab-completion on environment names. It really
95
- helps when you have a lot of environments and have trouble remembering their
96
- names.
97
- ``workon `` also deactivates whatever environment you are currently in, so you
105
+ **virtualenvwrapper ** provides tab-completion on environment names. It really
106
+ helps when you have a lot of environments and have trouble remembering their
107
+ names.
108
+ ``workon `` also deactivates whatever environment you are currently in, so you
98
109
can quickly switch between environments.
99
110
100
111
3. Deactivating is still the same:
@@ -116,8 +127,8 @@ Other useful commands
116
127
List all of the environments.
117
128
118
129
``cdvirtualenv ``
119
- Navigate into the directory of the currently activated virtual environment,
120
- so you can browse its ``site-packages ``, for example.
130
+ Navigate into the directory of the currently activated virtual environment,
131
+ so you can browse its ``site-packages ``, for example.
121
132
122
133
``cdsitepackages ``
123
134
Like the above, but directly into ``site-packages `` directory.
0 commit comments