Skip to content

Commit aff0be6

Browse files
committed
Apply @Kwpolska suggestion to scope to using pip in a virtual environment
1 parent 9e0b14b commit aff0be6

File tree

1 file changed

+79
-54
lines changed

1 file changed

+79
-54
lines changed

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

Lines changed: 79 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
Installing packages using pip and venv
2-
======================================
1+
Install packages in a virtual environment using pip and venv
2+
============================================================
33

4-
This guide discusses how to install packages using :ref:`pip` and
5-
the standard library's virtual environment :ref:`venv`. The guide
6-
covers how to:
4+
This guide discusses how to create and activate a virtual environment using
5+
the standard library's virtual environment :ref:`venv` and install packages.
6+
The guide covers how to:
77

8-
* Install and update pip
9-
* Create and use a virtual environment
8+
* Create and activate a virtual environment
9+
* Prepare pip
1010
* Install packages into a virtual environment using the ``pip`` command
1111
* Use and create a requirements file
1212

@@ -21,52 +21,11 @@ covers how to:
2121
import modules in your Python source code.
2222

2323

24-
Install and update pip
25-
----------------------
26-
27-
:ref:`pip` is the reference Python package manager.
28-
It's used to install and update packages.
29-
Make sure you have the latest version of pip installed.
30-
31-
32-
.. tab:: Unix/macOS
33-
34-
Debian and most other distributions include a `python-pip`_ package; if you
35-
want to use the Linux distribution-provided versions of pip, see
36-
:doc:`/guides/installing-using-linux-tools`.
37-
38-
You can also install pip yourself to ensure you have the latest version. It's
39-
recommended to use the system pip to bootstrap a user installation of pip:
40-
41-
.. code-block:: bash
42-
43-
python3 -m pip install --user --upgrade pip
44-
python3 -m pip --version
45-
46-
Afterwards, you should have the latest version of pip installed in your
47-
user site:
48-
49-
.. code-block:: text
50-
51-
pip 21.1.3 from $HOME/.local/lib/python3.9/site-packages (python 3.9)
52-
53-
.. _python-pip: https://packages.debian.org/stable/python/python3-pip
54-
55-
.. tab:: Windows
56-
57-
The Python installers for Windows include pip. You can make sure that pip is
58-
up-to-date by running:
59-
60-
.. code-block:: bat
61-
62-
py -m pip install --upgrade pip
63-
py -m pip --version
64-
65-
Afterwards, you should have the latest version of pip:
66-
67-
.. code-block:: text
68-
69-
pip 21.1.3 from c:\python39\lib\site-packages (Python 3.9.4)
24+
.. important::
25+
This guide has the prerequisite that an official Python version from
26+
<https://www.python.org/downloads/>. If you are using your operating
27+
system's package manager to install Python, please ensure that Python is
28+
installed before proceeding with these steps.
7029

7130

7231
Create and Use Virtual Environments
@@ -80,7 +39,7 @@ different projects. It creates a "virtual" isolated Python installation. When
8039
you switch projects, you can create a new virtual environment which is isolated
8140
from other virtual environments. You benefit from the virtual environment
8241
since packages can be installed confidently and will not interfere with the
83-
other project environments.
42+
another project's environment.
8443

8544
.. tip::
8645
It is recommended to use a virtual environment when working with third
@@ -185,6 +144,72 @@ instructions about activating a virtual environment. There's no need to create
185144
a new virtual environment.
186145

187146

147+
Prepare pip
148+
-----------
149+
150+
:ref:`pip` is the reference Python package manager.
151+
It's used to install and update packages into a virtual environment.
152+
153+
154+
.. tab:: Unix
155+
156+
Debian and most other distributions include a `python-pip`_ package; if you
157+
want to use the Linux distribution-provided versions of pip, see
158+
:doc:`/guides/installing-using-linux-tools`.
159+
160+
You can also install pip yourself to ensure you have the latest version. It's
161+
recommended to use the system pip to bootstrap a user installation of pip:
162+
163+
.. code-block:: bash
164+
165+
python3 -m pip install --user --upgrade pip
166+
python3 -m pip --version
167+
168+
Afterwards, you should have the latest version of pip installed in your
169+
user site:
170+
171+
.. code-block:: text
172+
173+
pip 21.1.3 from $HOME/.local/lib/python3.9/site-packages (python 3.9)
174+
175+
.. _python-pip: https://packages.debian.org/stable/python/python3-pip
176+
177+
.. tab:: macOS
178+
179+
The Python installers for macOS include pip. You can make sure that pip is
180+
up-to-date by running:
181+
182+
.. code-block:: bash
183+
184+
python3 -m pip install --upgrade pip
185+
python3 -m pip --version
186+
187+
Afterwards, you should have the latest version of pip installed in your
188+
user site:
189+
190+
.. code-block:: text
191+
192+
pip 21.1.3 from $HOME/.local/lib/python3.9/site-packages (python 3.9)
193+
194+
.. _python-pip: https://packages.debian.org/stable/python/python3-pip
195+
196+
.. tab:: Windows
197+
198+
The Python installers for Windows include pip. You can make sure that pip is
199+
up-to-date by running:
200+
201+
.. code-block:: bat
202+
203+
py -m pip install --upgrade pip
204+
py -m pip --version
205+
206+
Afterwards, you should have the latest version of pip:
207+
208+
.. code-block:: text
209+
210+
pip 21.1.3 from c:\python39\lib\site-packages (Python 3.9.4)
211+
212+
188213
Install packages using pip
189214
--------------------------
190215

0 commit comments

Comments
 (0)