Pip: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 23: Line 23:


=<tt>requirements.txt</tt> File=
=<tt>requirements.txt</tt> File=
The <code>requirements.txt</code> allows you to specify which packages and versions should be installed. Typically, the <code>requirements.txt</code> file is located in the root of the project.
The <code>requirements.txt</code> allows you to specify which packages and versions should be installed. Typically, the <code>requirements.txt</code> file is located in the root of the project. The  <code>requirements.txt</code> file can be generated with <code>[[#Freeze_Dependencies|pip freeze]]</code> command.
==Example==
==Example==
<syntaxhighlight lang='text'>
<syntaxhighlight lang='text'>
Line 34: Line 34:
virtualenv==16.3.0
virtualenv==16.3.0
</syntaxhighlight>
</syntaxhighlight>
=Version=
=Version=
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>

Revision as of 03:32, 11 January 2022

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