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
+22-8Lines changed: 22 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -226,23 +226,26 @@ Basic Usage
226
226
..code-block::console
227
227
228
228
$ cd my_project_folder
229
-
$ virtualenvmy_project
229
+
$ virtualenvvenv
230
230
231
-
``virtualenvmy_project`` will create a folder in the current directory which will
231
+
``virtualenvvenv`` will create a folder in the current directory which will
232
232
contain the Python executable files, and a copy of the ``pip`` library which you
233
233
can use to install other packages. The name of the virtual environment (in this
234
-
case, it was ``my_project``) can be anything; omitting the name will place the files
234
+
case, it was ``venv``) can be anything; omitting the name will place the files
235
235
in the current directory instead.
236
236
237
+
..note::
238
+
'venv' is the general convention used globally. As it is readily available in ignore files (eg: .gitignore')
239
+
237
240
This creates a copy of Python in whichever directory you ran the command in,
238
-
placing it in a folder named:file:`my_project`.
241
+
placing it in a folder named:file:`venv`.
239
242
240
243
You can also use the Python interpreter of your choice (like
241
244
``python2.7``).
242
245
243
246
..code-block::console
244
247
245
-
$ virtualenv -p /usr/bin/python2.7my_project
248
+
$ virtualenv -p /usr/bin/python2.7venv
246
249
247
250
or change the interpreter globally with an env variable in ``~/.bashrc``:
248
251
@@ -254,12 +257,20 @@ or change the interpreter globally with an env variable in ``~/.bashrc``:
254
257
255
258
..code-block::console
256
259
257
-
$ sourcemy_project/bin/activate
260
+
$ sourcevenv/bin/activate
258
261
259
262
The name of the current virtual environment will now appear on the left of
260
-
the prompt (e.g. ``(my_project)Your-Computer:your_project UserName$)`` to let you know
263
+
the prompt (e.g. ``(venv)Your-Computer:your_project UserName$)`` to let you know
261
264
that it's active. From now on, any package that you install using pip will be
262
-
placed in the ``my_project`` folder, isolated from the global Python installation.
265
+
placed in the ``venv`` folder, isolated from the global Python installation.
266
+
267
+
For Windows, same command which is mentioned in step 1 can be used for creation of virtual environment. But, to activate, we use the following command.
268
+
269
+
Assuming that you are in project directory:
270
+
271
+
..code-block::powershell
272
+
273
+
PS C:\Users\suryav> \venv\Scripts\activate
263
274
264
275
Install packages as usual, for example:
265
276
@@ -284,6 +295,9 @@ After a while, though, you might end up with a lot of virtual environments
284
295
littered across your system, and it's possible you'll forget their names or
285
296
where they were placed.
286
297
298
+
..note::
299
+
Python has included venv module from version 3.3. For more details: `venv<https://docs.python.org/3/library/venv.html>`_.