Python pip version linux

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 packages using pip and virtual environments¶

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

This doc uses the term package to refer to a Distribution Package which is different from an Import Package that which is used to import modules in your Python source code.

Installing pip¶

pip is the reference Python package manager. It’s used to install and update packages. You’ll need to make sure you have the latest version of pip installed.

Debian and most other distributions include a python-pip package; if you want to use the Linux distribution-provided versions of pip, see Installing pip/setuptools/wheel with Linux Package Managers .

You can also install pip yourself to ensure you have the latest version. It’s recommended to use the system pip to bootstrap a user installation of pip:

python3 -m pip install --user --upgrade pip python3 -m pip --version

Afterwards, you should have the latest version of pip installed in your user site:

pip 21.1.3 from $HOME/.local/lib/python3.9/site-packages (python 3.9)

The Python installers for Windows include pip. You can make sure that pip is up-to-date by running:

py -m pip install --upgrade pip py -m pip --version

Afterwards, you should have the latest version of pip:

pip 21.1.3 from c:\python39\lib\site-packages (Python 3.9.4)

Installing virtualenv¶

If you are using Python 3.3 or newer, the venv module is the preferred way to create and manage virtual environments. venv is included in the Python standard library and requires no additional installation. If you are using venv, you may skip this section.

virtualenv is used to manage Python packages for different projects. Using virtualenv allows you to avoid installing Python packages globally which could break system tools or other projects. You can install virtualenv using pip.

python3 -m pip install --user virtualenv
py -m pip install --user virtualenv

Creating a virtual environment¶

venv (for Python 3) and virtualenv (for Python 2) allow you to manage separate package installations for different projects. They essentially allow you to create a “virtual” isolated Python installation and install packages into that virtual installation. When you switch projects, you can simply create a new virtual environment and not have to worry about breaking the packages installed in the other environments. It is always recommended to use a virtual environment while developing Python applications.

To create a virtual environment, go to your project’s directory and run venv. If you are using Python 2, replace venv with virtualenv in the below commands.

The second argument is the location to create the virtual environment. Generally, you can just create this in your project and call it env .

venv will create a virtual Python installation in the env folder.

You should exclude your virtual environment directory from your version control system using .gitignore or similar.

Activating a virtual environment¶

Before you can start installing or using packages in your virtual environment you’ll need to activate it. Activating a virtual environment will put the virtual environment-specific python and pip executables into your shell’s PATH .

You can confirm you’re in the virtual environment by checking the location of your Python interpreter:

Источник

Python pip version linux

Pip — это пакетный менеджер для Python.

Если вы пользовались Debian / Ubuntu или Red Hat / CentOS / Rocky то уже сталкивались с пакетным менеджером apt, yum или dnf

Установка в Linux

Чтобы установить pip в Debian-подобных Linux выполните

sudo apt install python3-pip

Проверить успех установки можно с помощью

pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

Даже если Вы только что установили Python какие-то пакеты будут в системе по умолчанияю.

У меня, например, Flask и Jinja2 появились после установки Flask а остальные, похоже дефолтные.

Package Version —————— ——- astroid 2.4.1 click 7.1.2 colorama 0.4.3 Flask 1.1.2 isort 4.3.21 itsdangerous 1.1.0 Jinja2 2.11.2 lazy-object-proxy 1.4.3 MarkupSafe 1.1.1 mccabe 0.6.1 pip 20.1 pylint 2.5.2 setuptools 41.2.0 six 1.14.0 toml 0.10.0 Werkzeug 1.0.1 wrapt 1.12.1

Устанавливать какие-либо пакеты в систему не рекомендуется.

Рекомендуется всегда использовать виртуальное окружение .

Чтобы установить один пакет, например, Flask

python -m pip install flask

Чтобы установить сразу Flask, requests и Django

python -m pip install flask requests django

Не удаляет зависимости. Можно удалить как один пакет так и несколько сразу

pip uninstall flask requests django

pip list

pip list -o Покажет устаревшие пакеты

Package Version Latest Type —————— ——- —— —— lazy-object-proxy 1.4.3 1.5.0 wheel pip 20.1 20.1.1 wheel setuptools 41.2.0 47.1.1 wheel six 1.14.0 1.15.0 wheel toml 0.10.0 0.10.1 wheel

pip list -u Покажет пакеты с самой свежей версией

Package Version ———— ——- astroid 2.4.1 click 7.1.2 colorama 0.4.3 Flask 1.1.2 isort 4.3.21 itsdangerous 1.1.0 Jinja2 2.11.2 MarkupSafe 1.1.1 mccabe 0.6.1 pylint 2.5.2 Werkzeug 1.0.1 wrapt 1.12.1

pip show

pip show Покажет информацию о пакете

Name: Jinja2 Version: 2.11.2 Summary: A very fast and expressive template engine. Home-page: https://palletsprojects.com/p/jinja/ Author: Armin Ronacher Author-email: armin.ronacher@active-4.com License: BSD-3-Clause Location: c:\users\andrei\appdata\local\programs\python\python38-32\lib\site-packages Requires: MarkupSafe Required-by: Flask

Name: Flask Version: 1.1.2 Summary: A simple framework for building complex web applications. Home-page: https://palletsprojects.com/p/flask/ Author: Armin Ronacher Author-email: armin.ronacher@active-4.com License: BSD-3-Clause Location: /home/andrei/.local/lib/python3.7/site-packages Requires: Werkzeug, itsdangerous, Jinja2, click Required-by:

Искать пакеты онлайн можно на сайте pypi.org известный также под названием the cheese shop.

Если у Вас установлены и второй и третий Python, Вы можете прямо указать pip для какого Python делать установку.

python3.8 -m pip install flask

Установить определённую версию пакета

Допустим, Вам нужна версия flask 1.0

python -m pip install flask==1.0

Или Django не старше второй версии

python -m pip install ‘Django

Обновить версию пакета

Если Вам нужно обновить, например, flask до последней версии — нужно использовать install с флагом -U

python -m pip install -U flask

Обновить версию pip

Если pip старый он сам подсказывает, что его нужно обновить предупреждением

WARNING: You are using pip version 19.2.3, however version 20.1.1 is available.
You should consider upgrading via the ‘python -m pip install —upgrade pip’ command.

Чтобы обновить pip выполните

python -m pip install -U pip

python -m pip install —upgrade pip

Установить пакет из директории

Если Вы скачали пакет и хотите выполнить установку из папки — нужно использовать флаг -e

python -m pip install -e flask

WARNING: pip is being invoked by an old script wrapper

При выполнении pip может появиться предупреждение

WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with ‘-m pip’ instead of running pip directly.
pip 20.3.3 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

Чтобы его избежать вызывайте pip через python

pip 20.3.3 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

Установить пакет для определённой версии Python

Если у вас несколько версий Python и нужно установить какой-то пакет только для определённой версии, назовём её X.X, воспользуйтесь командой

pythonX.X -m pip install название_пакета —user —ignore-installed

Источник

Читайте также:  Multithreading in c linux
Оцените статью
Adblock
detector