Skip to content

Added windows virtual environment activation command. Closes #942 #946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions docs/dev/virtualenvs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``:

Expand All @@ -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\Scripts\activate

Install packages as usual, for example:

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

.. note::
Python has included venv module from version 3.3. For more details: `venv <https://docs.python.org/3/library/venv.html>`_.

Other Notes
~~~~~~~~~~~

Expand Down