Python pip linux debian

Как установить Pip на Debian 9

Pip — это система управления пакетами, которая упрощает установку и управление пакетами программного обеспечения, написанными на Python, такими как те, которые находятся в индексе пакетов Python (PyPI) .

Это руководство проведет вас через установку Python Pip в Debian 9 и научит, как устанавливать пакеты Python и управлять ими с помощью pip.

Подготовка

Прежде чем продолжить это руководство, убедитесь, что вы вошли в систему как пользователь с привилегиями sudo .

Стоит отметить, что если вы хотите установить модуль python глобально, вы должны предпочесть установить его как пакет с помощью менеджера apt . Используйте pip для глобальной установки модулей Python, только если пакет недоступен.

Обычно вы используете pip только внутри виртуальной среды. Virtual Environment Python позволяет устанавливать модули Python в изолированном месте для конкретного проекта, а не глобально. Таким образом, вам не нужно беспокоиться о влиянии на другие проекты Python.

В следующих разделах мы покажем вам, как установить pip для Python 2 pip и Python 3 pip3 с помощью диспетчера пакетов apt .

Установите Pip для Python 2

Выполните следующие действия, чтобы установить Pip для Python 2 в вашей системе Debian:

    Начните с обновления индекса пакетов:

sudo apt install python-pip
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)

Установить pip для Python 3

Выполните следующие действия, чтобы установить Pip для Python 3 в Debian:

    Сначала обновите список пакетов:

sudo apt install python3-pip
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)

Использование пункта

В этом разделе мы покажем вам несколько полезных базовых команд pip. С помощью pip мы можем устанавливать пакеты из PyPI, системы контроля версий, локальных проектов и из файлов распространения, но в большинстве случаев вы будете устанавливать пакеты из PyPI.

Допустим, мы хотим установить пакет с именем croniter , мы можем сделать это, выполнив следующую команду:

Чтобы удалить пакет, выполните:

pip uninstall package_name

Для поиска пакетов из PyPI:

Чтобы просмотреть установленные пакеты:

Чтобы перечислить устаревшие пакеты:

Package Version Latest Type ------------- ------- ------ ----- cryptography 1.7.1 2.2.2 wheel enum34 1.1.6 1.1.6 wheel idna 2.2 2.7 wheel ipaddress 1.0.17 1.0.22 wheel keyring 10.1 13.0.0 wheel keyrings.alt 1.3 3.1 wheel pip 9.0.1 10.0.1 wheel pyasn1 0.1.9 0.4.3 wheel pycrypto 2.6.1 2.6.1 sdist pygobject 3.22.0 3.28.3 sdist pyxdg 0.25 0.26 wheel SecretStorage 2.3.1 2.3.1 sdist setuptools 33.1.1 39.2.0 wheel six 1.10.0 1.11.0 wheel wheel 0.29.0 0.31.1 wheel 

Выводы

В этом руководстве мы показали вам, как установить pip в вашей системе Debian и как управлять пакетами Python с помощью pip. Дополнительные сведения о pip см. В руководстве пользователя pip .

Если у вас есть какие-либо вопросы или отзывы, не стесняйтесь оставлять комментарии ниже.

Источник

Installation#

If your Python environment does not have pip installed, there are 2 mechanisms to install pip supported directly by pip’s maintainers:

ensurepip #

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

$ python -m ensurepip --upgrade
$ python -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:

More details about this script can be found in pypa/get-pip’s README.

Standalone zip application#

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:

then the currently active Python interpreter will be used.

Alternative Methods#

Depending on how you installed Python, there might be other mechanisms available to you for installing pip such as using Linux package managers .

These mechanisms are provided by redistributors of pip, who may have modified pip to change its behaviour. This has been a frequent source of user confusion, since it causes a mismatch between documented behaviour in this documentation and how pip works after those modifications.

If you face issues when using Python and pip installed using these mechanisms, it is recommended to request for support from the relevant provider (eg: Linux distro community, cloud provider support channels, etc).

Upgrading pip #

Upgrade your pip by running:

$ python -m pip install --upgrade pip
$ python -m pip install --upgrade pip
C:> py -m pip install --upgrade pip

Compatibility#

The current version of pip works on:

pip is tested to work on the latest patch version of the Python interpreter, for each of the minor versions listed above. Previous patch versions are supported on a best effort approach.

Other operating systems and Python versions are not supported by pip’s maintainers.

Users who are on unsupported platforms should be aware that if they hit issues, they may have to resolve them for themselves. If they received pip from a source which provides support for their platform, they should request pip support from that source.

The ensurepip module was added to the Python standard library in Python 3.4.

Источник

Installation#

If your Python environment does not have pip installed, there are 2 mechanisms to install pip supported directly by pip’s maintainers:

ensurepip #

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

$ python -m ensurepip --upgrade
$ python -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:

More details about this script can be found in pypa/get-pip’s README.

Standalone zip application#

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:

then the currently active Python interpreter will be used.

Alternative Methods#

Depending on how you installed Python, there might be other mechanisms available to you for installing pip such as using Linux package managers .

These mechanisms are provided by redistributors of pip, who may have modified pip to change its behaviour. This has been a frequent source of user confusion, since it causes a mismatch between documented behaviour in this documentation and how pip works after those modifications.

If you face issues when using Python and pip installed using these mechanisms, it is recommended to request for support from the relevant provider (eg: Linux distro community, cloud provider support channels, etc).

Upgrading pip #

Upgrade your pip by running:

$ python -m pip install --upgrade pip
$ python -m pip install --upgrade pip
C:> py -m pip install --upgrade pip

Compatibility#

The current version of pip works on:

pip is tested to work on the latest patch version of the Python interpreter, for each of the minor versions listed above. Previous patch versions are supported on a best effort approach.

Other operating systems and Python versions are not supported by pip’s maintainers.

Users who are on unsupported platforms should be aware that if they hit issues, they may have to resolve them for themselves. If they received pip from a source which provides support for their platform, they should request pip support from that source.

The ensurepip module was added to the Python standard library in Python 3.4.

Источник

Installing pip/setuptools/wheel with Linux Package Managers¶

This section covers how to install pip , setuptools , and wheel using Linux package managers.

If you’re using a Python that was downloaded from python.org, then this section does not apply. See the Requirements for Installing Packages section instead.

Note that it’s common for the versions of pip , setuptools , and wheel supported by a specific Linux Distribution to be outdated by the time it’s released to the public, and updates generally only occur for security reasons, not for feature updates. For certain Distributions, there are additional repositories that can be enabled to provide newer versions. The repositories we know about are explained below.

Also note that it’s somewhat common for Distributions to apply patches for the sake of security and normalization to their own standards. In some cases, this can lead to bugs or unexpected behaviors that vary from the original unpatched versions. When this is known, we will make note of it below.

Fedora¶

sudo dnf install python3-pip python3-wheel

To learn more about Python in Fedora, please visit the official Fedora docs, Python Classroom or Fedora Loves Python.

CentOS/RHEL¶

CentOS and RHEL don’t offer pip or wheel in their core repositories, although setuptools is installed by default.

To install pip and wheel for the system Python, there are two options:

    Enable the EPEL repository using these instructions. On EPEL 7, you can install pip and wheel like so:

sudo dnf install python3-pip python3-wheel
sudo dnf install python3-pip python3-wheel
sudo dnf upgrade python3-setuptools

To install pip, wheel, and setuptools, in a parallel, non-system environment (using yum) then there are two options:

  1. Use the “Software Collections” feature to enable a parallel collection that includes pip, setuptools, and wheel.
    • For Redhat, see here: https://developers.redhat.com/products/softwarecollections/overview
    • For CentOS, see here: https://github.com/sclorg

Be aware that collections may not contain the most recent versions.

sudo yum install python34u python34u-wheel

openSUSE¶

sudo zypper install python3-pip python3-setuptools python3-wheel

Debian/Ubuntu and derivatives¶

Firstly, update and refresh repository lists by running this command:

sudo apt update sudo apt install python3-venv python3-pip

Recent Debian/Ubuntu versions have modified pip to use the “User Scheme” by default, which is a significant behavior change that can be surprising to some users.

Arch Linux¶

Currently, there is no “copr” yum plugin available for CentOS/RHEL, so the only option is to manually place the repo files as described.

Table of Contents

Оцените статью