Skip to content

Commit 9d975b5

Browse files
authored
Merge pull request realpython#946 from suryasr007/master
Added windows virtual environment activation command. Closes realpython#942
2 parents 831ccee + dc85a33 commit 9d975b5

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

docs/dev/virtualenvs.rst

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,23 +226,26 @@ Basic Usage
226226
.. code-block:: console
227227
228228
$ cd my_project_folder
229-
$ virtualenv my_project
229+
$ virtualenv venv
230230
231-
``virtualenv my_project`` will create a folder in the current directory which will
231+
``virtualenv venv`` will create a folder in the current directory which will
232232
contain the Python executable files, and a copy of the ``pip`` library which you
233233
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
235235
in the current directory instead.
236236

237+
.. note::
238+
'venv' is the general convention used globally. As it is readily available in ignore files (eg: .gitignore')
239+
237240
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`.
239242

240243
You can also use the Python interpreter of your choice (like
241244
``python2.7``).
242245

243246
.. code-block:: console
244247
245-
$ virtualenv -p /usr/bin/python2.7 my_project
248+
$ virtualenv -p /usr/bin/python2.7 venv
246249
247250
or change the interpreter globally with an env variable in ``~/.bashrc``:
248251

@@ -254,12 +257,20 @@ or change the interpreter globally with an env variable in ``~/.bashrc``:
254257

255258
.. code-block:: console
256259
257-
$ source my_project/bin/activate
260+
$ source venv/bin/activate
258261
259262
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
261264
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
263274
264275
Install packages as usual, for example:
265276

@@ -284,6 +295,9 @@ After a while, though, you might end up with a lot of virtual environments
284295
littered across your system, and it's possible you'll forget their names or
285296
where they were placed.
286297

298+
.. note::
299+
Python has included venv module from version 3.3. For more details: `venv <https://docs.python.org/3/library/venv.html>`_.
300+
287301
Other Notes
288302
~~~~~~~~~~~
289303

0 commit comments

Comments
 (0)