Installation – pip documentation v23.1.1
Usually, pip is automatically installed if you are:
using Python that has not been modified by a redistributor to remove ensurepip
Mục lục bài viết
Supported Methods#
If your Python environment does not have pip installed, there are 2 mechanisms
to install pip supported directly by pip’s maintainers:
ensurepip
#
ensurepip
Python comes with an ensurepip
module , which can install pip in
a Python environment.
Linux
$
python-m
ensurepip
--upgrade
MacOS
$
python-m
ensurepip
--upgrade
Windows
C:>
py -m ensurepip --upgrade
More details about how ensurepip
works and how it can be used, is
available in the standard library documentation.
get-pip.py
#
get-pip.py
This is a Python script that uses some bootstrapping logic to install
pip.
-
Download the script, from https://bootstrap.pypa.io/get-pip.py.
-
Open a terminal/command prompt,
cd
to the folder containing the
get-pip.py
file and run:Linux
$
pythonMacOS
$
pythonWindows
C:>
py get-pip.py
More details about this script can be found in pypa/get-pip’s README.
Standalone zip application#
Note
The zip application is currently experimental. We test that pip runs correctly
in this form, but it is possible that there could be issues in some situations.
We will accept bug reports in such cases, but for now the zip application should
not be used in production environments.
In addition to installing pip in your environment, pip is available as a
standalone zip application.
This can be downloaded from https://bootstrap.pypa.io/pip/pip.pyz. There are
also zip applications for specific pip versions, named pip-X.Y.Z.pyz
.
The zip application can be run using any supported version of Python:
Linux
$
pythonpip.pyz
--help
MacOS
$
pythonpip.pyz
--help
Windows
C:>
py pip.pyz --help
If run directly:
Linux
$
python-m
pip.pyz
--help
MacOS
$
python-m
pip.pyz
--help
Windows
C:>
py -m pip.pyz --help
then the currently active Python interpreter will be used.