Skip to content

Commit 84c5747

Browse files
Chad Smithncoghlan
authored andcommitted
reduce emphasis on virtualenv (#606)
1 parent 9683e8d commit 84c5747

3 files changed

Lines changed: 43 additions & 38 deletions

File tree

source/guides/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ introduction to packaging, see :doc:`/tutorials/index`.
99
:maxdepth: 1
1010

1111
tool-recommendations
12-
installing-using-pip-and-virtualenv
12+
installing-using-pip-and-virtual-environments
1313
installing-stand-alone-command-line-tools
1414
installing-using-linux-tools
1515
installing-scientific-packages

source/guides/installing-using-pip-and-virtualenv.rst renamed to source/guides/installing-using-pip-and-virtual-environments.rst

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
Installing packages using pip and virtualenv
2-
============================================
1+
Installing packages using pip and virtual environments
2+
======================================================
33

44
This guide discusses how to install packages using :ref:`pip` and
5-
:ref:`virtualenv`. These are the lowest-level tools for managing Python
5+
a virtual environment manager: either :ref:`venv` for Python 3 or :ref:`virtualenv`
6+
for Python 2. These are the lowest-level tools for managing Python
67
packages and are recommended if higher-level tools do not suit your needs.
78

89
.. note:: This doc uses the term **package** to refer to a
@@ -63,6 +64,12 @@ Afterwards, you should have the newest pip installed in your user site:
6364
Installing virtualenv
6465
---------------------
6566

67+
.. Note:: If you are using Python 3.3 or newer, the :mod:`venv` module is
68+
the preferred way to create and manage virtual environments.
69+
venv is included in the Python standard library and requires no additional installation.
70+
If you are using venv, you may skip this section.
71+
72+
6673
:ref:`virtualenv` is used to manage Python packages for different projects.
6774
Using virtualenv allows you to avoid installing Python packages globally
6875
which could break system tools or other projects. You can install virtualenv
@@ -81,51 +88,50 @@ On Windows:
8188
py -m pip install --user virtualenv
8289
8390
84-
.. Note:: If you are using Python 3.3 or newer the :mod:`venv` module is
85-
included in the Python standard library. This can also create and manage
86-
virtual environments, however, it only supports Python 3.
87-
8891
89-
Creating a virtualenv
90-
---------------------
92+
Creating a virtual environment
93+
------------------------------
9194

92-
:ref:`virtualenv` allows you to manage separate package installations for
93-
different projects. It essentially allows you to create a "virtual" isolated
95+
:ref:`venv` (for Python 3) and :ref:`virtualenv` (for Python 2) allow
96+
you to manage separate package installations for
97+
different projects. They essentially allow you to create a "virtual" isolated
9498
Python installation and install packages into that virtual installation. When
9599
you switch projects, you can simply create a new virtual environment and not
96100
have to worry about breaking the packages installed in the other environments.
97-
It is always recommended to use a virtualenv while developing Python
101+
It is always recommended to use a virtual environment while developing Python
98102
applications.
99103

100104
To create a virtual environment, go to your project's directory and run
101-
virtualenv.
105+
venv. If you are using Python 2, replace ``venv`` with ``virtualenv``
106+
in the below commands.
102107

103108
On macOS and Linux:
104109

105110
.. code-block:: bash
106111
107-
python3 -m virtualenv env
112+
python3 -m venv env
108113
109114
On Windows:
110115

111116
.. code-block:: bash
112117
113-
py -m virtualenv env
118+
py -m venv env
114119
115-
The second argument is the location to create the virtualenv. Generally, you
120+
The second argument is the location to create the virtual environment. Generally, you
116121
can just create this in your project and call it ``env``.
117122

118-
virtualenv will create a virtual Python installation in the ``env`` folder.
123+
venv will create a virtual Python installation in the ``env`` folder.
119124

120-
.. Note:: You should exclude your virtualenv directory from your version
125+
.. Note:: You should exclude your virtual environment directory from your version
121126
control system using ``.gitignore`` or similar.
122127

123128

124-
Activating a virtualenv
125-
-----------------------
129+
Activating a virtual environment
130+
--------------------------------
126131

127-
Before you can start installing or using packages in your virtualenv you'll
128-
need to *activate* it. Activating a virtualenv will put the virtualenv-specific
132+
Before you can start installing or using packages in your virtual environment you'll
133+
need to *activate* it. Activating a virtual environment will put the
134+
virtual environment-specific
129135
``python`` and ``pip`` executables into your shell's ``PATH``.
130136

131137
On macOS and Linux:
@@ -138,7 +144,7 @@ On Windows::
138144

139145
.\env\Scripts\activate
140146

141-
You can confirm you're in the virtualenv by checking the location of your
147+
You can confirm you're in the virtual environment by checking the location of your
142148
Python interpreter, it should point to the ``env`` directory.
143149

144150
On macOS and Linux:
@@ -156,28 +162,28 @@ On Windows:
156162
.../env/bin/python.exe
157163
158164
159-
As long as your virtualenv is activated pip will install packages into that
165+
As long as your virtual environment is activated pip will install packages into that
160166
specific environment and you'll be able to import and use packages in your
161167
Python application.
162168

163169

164-
Leaving the virtualenv
165-
----------------------
170+
Leaving the virtual environment
171+
-------------------------------
166172

167-
If you want to switch projects or otherwise leave your virtualenv, simply run:
173+
If you want to switch projects or otherwise leave your virtual environment, simply run:
168174

169175
.. code-block:: bash
170176
171177
deactivate
172178
173-
If you want to re-enter the virtualenv just follow the same instructions above
174-
about activating a virtualenv. There's no need to re-create the virtualenv.
179+
If you want to re-enter the virtual environment just follow the same instructions above
180+
about activating a virtual environment. There's no need to re-create the virtual environment.
175181

176182

177183
Installing packages
178184
-------------------
179185

180-
Now that you're in your virtualenv you can install packages. Let's install the
186+
Now that you're in your virtual environment you can install packages. Let's install the
181187
excellent `Requests`_ library from the :term:`Python Package Index (PyPI)`:
182188

183189
.. code-block:: bash

source/tutorials/installing-packages.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,24 +194,23 @@ Currently, there are two common tools for creating Python virtual environments:
194194

195195
The basic usage is like so:
196196

197-
Using :ref:`virtualenv`:
197+
Using `venv`_:
198198

199199
::
200200

201-
virtualenv <DIR>
201+
python3 -m venv <DIR>
202202
source <DIR>/bin/activate
203203

204-
205-
Using `venv`_:
204+
Using :ref:`virtualenv`:
206205

207206
::
208207

209-
python3 -m venv <DIR>
208+
virtualenv <DIR>
210209
source <DIR>/bin/activate
211210

212211

213-
For more information, see the `virtualenv <http://virtualenv.pypa.io>`_ docs or
214-
the `venv`_ docs.
212+
213+
For more information, see the `venv`_ docs or the `virtualenv <http://virtualenv.pypa.io>`_ docs.
215214

216215
In both of the above cases, Windows users should _not_ use the
217216
`source` command, but should rather run the `activate` script directly

0 commit comments

Comments
 (0)