Pip

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

External

Internal

Overview

pip is the standard package manager for Python, that allows you install and manage package that are not part of the Python standard library. pip has been included with the Python installer since 3.4. pip looks for packages in PyPI

Installation

CentOS

https://linuxize.com/post/how-to-install-pip-on-centos-7/
yum install epel-release # On Amazon Linux, it works without this
yum install python-pip

Upgrade

python -m pip install --upgrade pip

requirements.txt File

The requirements.txt allows you to specify which packages and versions should be installed. Typically, the requirements.txt file is located in the root of the project. The requirements.txt file can be generated with pip freeze command.

Example

pyOpenSSL==0.13.1
pyparsing==2.0.1
python-dateutil==1.5
pytz==2013.7
scipy==0.13.0b1
six==1.4.1
virtualenv==16.3.0

Version

pip --version

Operations

List Packages Installed in Environment

pip list

Display Details about a Package

pip show <package-name>

Install a Package

pip install <package-name>

The command always looks for the latest version of the package and installs it. It also looks for dependencies listed in the package metadata and installs those dependencies as well.

Upgrade a Package

Freeze Dependencies

Used to create requirements.txt files.

pip freeze > requirements.txt