Pip (package manager)

{{short description|Package management system for Python}}

{{use dmy dates|date=June 2018}}

{{primary sources|date=November 2022}}{{lowercase title}}

{{Infobox software

| name = pip

| logo =

| screenshot = Pip help.png

| caption = An output of pip --help

| author = Ian Bicking

| released = {{start date and age|2008|10|28|df=yes|paren=yes}}{{Cite web |url=https://pypi.org/project/pip/0.2/ |title=Pip 0.2 |website=PyPI |access-date=27 August 2024 }}

| latest release version = {{wikidata|property|preferred|references|edit|P348|P548=Q2804309}}

| latest release date = {{Start date and age|{{wikidata|qualifier|preferred|single|P348|P548=Q2804309|P577}}|df=yes}}

| programming language = Python

| operating system = OS-independent

| platform = Python

| genre = Package management system

| license = MIT{{cite web |title=pip/LICENSE.txt |url=https://github.com/pypa/pip/blob/master/LICENSE.txt |date=17 April 2018 |website=Github |accessdate=1 June 2018 |archiveurl=https://web.archive.org/web/20180601113651/https://github.com/pypa/pip/blob/master/LICENSE.txt |archivedate=1 June 2018 |url-status=live}}

| website = {{url|https://pip.pypa.io}}

}}

pip (also known by Python 3's alias pip3) is a package-management system written in Python and is used to install and manage software packages.{{cite web |last1=Kollár |first1=László |title=Managing Python packages the right way |url=https://opensource.com/article/19/4/managing-python-packages |accessdate=23 June 2019 |website=Opensource.com |publisher=Red Hat |language=en}} The Python Software Foundation recommends using pip for installing Python applications and its dependencies during deployment.{{Cite web |title=Tool recommendations — Python Packaging User Guide |url=https://packaging.python.org/en/latest/guides/tool-recommendations/ |access-date=2022-11-09 |website=packaging.python.org}} Pip connects to an online repository of public packages, called the Python Package Index. Pip can be configured to connect to other package repositories (local or remote), provided that they comply to Python Enhancement Proposal 503.{{cite web |title=Python Enhancement Proposal 503 |url=https://www.python.org/dev/peps/pep-0503 |website=python.org}}{{cite web |title=pip install command line documentation |url=https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-0 |website=pip.pypa.io}}

Most distributions of Python come with pip preinstalled. Python 2.7.9 and later (on the python2 series), and Python 3.4 and later include pip by default.{{cite web |title=pip installation |url=https://pip.pypa.io/en/latest/installing.html |accessdate=24 Feb 2015}}

History

First introduced as pyinstall in 2008 by Ian Bicking (the creator of the virtualenv package) as an alternative to easy install,{{cite web |last=Bicking |first=Ian |date=24 September 2008 |title=pyinstall: A New Hope |url=http://www.openplans.org/projects/topp-engineering/blog/2008/09/24/pyinstall-a-new-hope/ |archive-url=https://web.archive.org/web/20080927034025/http://www.openplans.org/projects/topp-engineering/blog/2008/09/24/pyinstall-a-new-hope/ |archive-date=27 September 2008 |accessdate=4 March 2020}}{{cite web |title=Packaging History |url=https://www.pypa.io/en/latest/history/ |accessdate=4 March 2020 |website=Python Packaging Authority}} pip was chosen as the new name from one of several suggestions that the creator received on his blog post.{{cite web |last=Bicking |first=Ian |date=1 October 2008 |title=pyinstall pybundles |url=https://www.ianbicking.org/blog/2008/10/pyinstall-pybundles.html |accessdate=24 November 2021}} According to Bicking himself, the name is a recursive acronym for "Pip Installs Packages".{{cite web |last=Bicking |first=Ian |date=28 October 2008 |title=pyinstall is dead, long live pip! |url=https://www.ianbicking.org/blog/2008/10/pyinstall-is-dead-long-live-pip.html |accessdate=24 November 2021}} In 2011, the Python Packaging Authority (PyPA) was created to take over the maintenance of pip and virtualenv from Bicking, led by Carl Meyer, Brian Rosner, and Jannis Leidel.

With the release of pip version 6.0 (2014-12-22), the version naming process was changed to have version in X.Y format and drop the preceding 1 from the version label.{{cite web | url=https://pip.pypa.io/en/stable/news/#id443 | title=Changelog - pip documentation v22.3.1 }}

Command-line interface

File:Pip install virtualenv.png

Pip's command-line interface allows the install of Python software packages by issuing a command: pip install some-package-name

Users can also remove the package by issuing a command: pip uninstall some-package-name

pip has a feature to manage full lists of packages and corresponding version numbers, possible through a "requirements" file.{{cite web |title=pip documentation |url=http://www.pip-installer.org/ |accessdate=5 January 2012 |publisher=The pip developers}} This permits the efficient re-creation of an entire group of packages in a separate environment (e.g. another computer) or virtual environment. This can be achieved with a properly formatted file and the following command,{{cite web |last1=Gahlot |first1=Gaurav |date=6 November 2018 |title=Most Important pip Commands for a Python Developer - DZone Open Source |url=https://dzone.com/articles/most-important-quotpipquot-commands-for-a-python-d |accessdate=23 June 2019 |website=dzone.com |language=en}} where requirements.txt is the name of the file: pip install -r requirements.txt.

To install some package for a specific python version, pip provides the following command, where ${version} is replaced by 2, 3, 3.4, etc.: pip${version} install some-package-name.

= Using {{mono|setup.py}} =

Pip provides a way to install user-defined projects locally with the use of {{mono|setup.py}} file. This method requires the Python project to have the following file structure:

example_project/

├── exampleproject/ Python package with source code.

| ├── __init__.py Make the folder a package.

|  └── example.py Example module.

└── README.md README with info of the project.

Within this structure, user can add {{mono|setup.py}} to the root of the project (i.e. {{code|example_project}} for above structure) with the following content:

from setuptools import setup, find_packages

setup(

name="example", # Name of the package. This will be used, when the project is imported as a package.

version="0.1.0",

packages=find_packages(include=["exampleproject", "exampleproject.*"]) # Pip will automatically install the dependencies provided here.

)

After this, pip can install this custom project by running the following command, from the project root directory: pip install -e.

Custom repository

Besides the default PyPI repository, Pip supports custom repositories as well.{{cite web |title=Custom repository with pip install -i |url=https://python.land/virtual-environments/installing-packages-with-pip#Custom_repository_with_pip_install_-i |accessdate=12 Jan 2022}} Such repositories can be located on an HTTP(s) URL or on a file system location.

A custom repository can be specified using the {{code|-i}} or {{code|--index-url}} option, like so: pip install -i https://your-custom-repo/simple ; or with a filesystem: pip install -i /path/to/your/custom-repo/simple .

See also

References

{{Reflist|30em}}