Added windows virtual environment activation command. Closes #942

This commit is contained in:
Surya Teja
2018-12-16 19:08:05 +05:30
parent cafe323e0e
commit af9971071b
+22 -8
View File
@@ -226,23 +226,26 @@ Basic Usage
.. code-block:: console
$ cd my_project_folder
$ virtualenv my_project
$ virtualenv venv
``virtualenv my_project`` will create a folder in the current directory which will
``virtualenv venv`` will create a folder in the current directory which will
contain the Python executable files, and a copy of the ``pip`` library which you
can use to install other packages. The name of the virtual environment (in this
case, it was ``my_project``) can be anything; omitting the name will place the files
case, it was ``venv``) can be anything; omitting the name will place the files
in the current directory instead.
.. note::
'venv' is the general convention used globally. As it is readily available in ignore files (eg: .gitignore')
This creates a copy of Python in whichever directory you ran the command in,
placing it in a folder named :file:`my_project`.
placing it in a folder named :file:`venv`.
You can also use the Python interpreter of your choice (like
``python2.7``).
.. code-block:: console
$ virtualenv -p /usr/bin/python2.7 my_project
$ virtualenv -p /usr/bin/python2.7 venv
or change the interpreter globally with an env variable in ``~/.bashrc``:
@@ -254,12 +257,20 @@ or change the interpreter globally with an env variable in ``~/.bashrc``:
.. code-block:: console
$ source my_project/bin/activate
$ source venv/bin/activate
The name of the current virtual environment will now appear on the left of
the prompt (e.g. ``(my_project)Your-Computer:your_project UserName$)`` to let you know
the prompt (e.g. ``(venv)Your-Computer:your_project UserName$)`` to let you know
that it's active. From now on, any package that you install using pip will be
placed in the ``my_project`` folder, isolated from the global Python installation.
placed in the ``venv`` folder, isolated from the global Python installation.
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.
Assuming that, you are in project directory:
.. code-block:: powershell
PS C:\Users\suryav> \venv\bin\activate
Install packages as usual, for example:
@@ -284,6 +295,9 @@ After a while, though, you might end up with a lot of virtual environments
littered across your system, and its possible you'll forget their names or
where they were placed.
.. note::
Python has included virtual environment module from 3.3. It works in the simliar way as mentioned above. For details: `venv <https://docs.python.org/3/library/venv.html>`_.
Other Notes
~~~~~~~~~~~