pip (package manager)

From Wikipedia, the free encyclopedia
  (Redirected from Pip (Python))
Jump to navigation Jump to search

pip
An output of pip --help
An output of pip --help
Original author(s)Ian Bicking
Initial release4 April 2011 (9 years ago) (2011-04-04)[1]
Stable release
21.0 / 23 January 2021 (30 days ago) (2021-01-23)[2]
Repository Edit this at Wikidata
Written inPython
Operating systemOS-independent
PlatformPython
TypePackage management system
LicenseMIT[3]
Websitepip.pypa.io

pip is a package-management system written in Python used to install and manage software packages.[4] It connects to an online repository of public and paid-for private packages, called the Python Package Index.

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 (pip3 for Python 3) by default.[5] Python 2.7 (and 3.5) support was dropped with the next release, pip 21, in January 2021.[6]

History[edit]

First introduced as pyinstall in 2008 by Ian Bicking (the creator of the virtualenv package) as an alternative to easy_install,[7][8] pip was chosen as the new name from one of several suggestions that the creator received on his blog post.[9] According to Bicking himself, the name is a recursive acronym for "Pip Installs Packages".[10] 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.[8]

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.

Command-line interface[edit]

An output of pip install virtualenv

One major advantage of pip is the ease of its command-line interface, which makes installing Python software packages as easy as issuing a command:

pip install some-package-name

Users can also easily remove the package:

pip uninstall some-package-name

Most importantly, pip has a feature to manage full lists of packages and corresponding version numbers, possible through a "requirements" file.[11] 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,[12] 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 setup.py[edit]

Pip provides a way to install user-defined projects locally with the use of 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 setup.py to the root of the project (i.e. 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 dependences provided here.
)

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

pip install -e .

See also[edit]

References[edit]

  1. ^ Release 1.0
  2. ^ "Changelog - pip documentation v21.0". pip.pypa.io. Retrieved 25 January 2021.
  3. ^ "pip/LICENSE.txt". Github. 17 April 2018. Archived from the original on 1 June 2018. Retrieved 1 June 2018.
  4. ^ Kollár, László. "Managing Python packages the right way". Opensource.com. Red Hat. Retrieved 23 June 2019.
  5. ^ "pip installation". Retrieved 24 February 2015.
  6. ^ Harihareswara, Sumana (30 November 2020). "Python Insider: Releasing pip 20.3, featuring new dependency resolver". Python Insider. Retrieved 4 December 2020.
  7. ^ Bicking, Ian (24 September 2008). "pyinstall: A New Hope". Archived from the original on 27 September 2008. Retrieved 4 March 2020.
  8. ^ a b "Packaging History". Python Packaging Authority. Retrieved 4 March 2020.
  9. ^ Bicking, Ian (1 October 2008). "pyinstall pybundles". Retrieved 4 March 2020.
  10. ^ Bicking, Ian (28 October 2008). "pyinstall is dead, long live pip!". Retrieved 4 March 2020.
  11. ^ "pip documentation". The pip developers. Retrieved 5 January 2012.
  12. ^ Gahlot, Gaurav (6 November 2018). "Most Important pip Commands for a Python Developer - DZone Open Source". dzone.com. Retrieved 23 June 2019.

External links[edit]