Installation - Pip Documentation V22.1.2

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

  • get-pip.py

ensurepip

Python comes with an ensurepip module[1], which can install pip in a Python environment.

Linux $ python-mensurepip--upgrade MacOS $ python-mensurepip--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

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 $ pythonget-pip.py MacOS $ pythonget-pip.py Windows 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 $ chmod+x./pip.pyz $ ./pip.pyz

then the currently active Python interpreter will be used.

MacOS $ chmod+x./pip.pyz $ ./pip.pyz

then the currently active Python interpreter will be used.

Windows C:> .\pip.pyz

then the currently active Python interpreter will be used.

You may need to configure your system to recognise the .pyz extension before this will work.

Từ khóa » Cài đặt Python 2.7