How to use Pip and PyPI

A pip command is a tool for installing and managing Python packages, such as
those found in the Python Package Index.

It’s a replacement for easy_install.

PIP Installation

Installing PIP is easy and if you’re running Linux, its usually already installed.

If it’s not installed or if the current version is outdated, you can use the
package manager to install or update it.

On Debian and Ubuntu:

$ sudo apt-get install python-pip

On Fedora:

$ sudo yum install python-pip

If you are using Mac, you can simply install it through easy_install:

sudo easy_install pip

PyPI – the Python Package Index

Now, when PIP is installed, we need to find a package to install.

Packages are usually installed from the Python Package Index.

The Python Package Index is a repository of software for the Python programming language.

Getting Started with PIP

Now, when we know what PIP is and we have it installed on the computer,
let’s see how to use it.

To install a package from the Python Package Index, just open up your terminal
and type in a search query using the PIP tool.

PIP – Commands

Just typing pip in your terminal, should give you the following output on the
screen:

Usage:
pip [options]

Commands:
install Install packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
search Search PyPI for packages.
zip Zip individual packages.
unzip Unzip individual packages.
bundle Create pybundles.
help Show help for commands.

The most common usage for pip is to install, upgrade or uninstall a package.

PIP – Search

To search for a package, say Flask, type in the following:

pip search Flask

You should see an output with all packages containing the name “Flask” and
a description with that.

Flask-Cache – Adds cache support to your Flask application
Flask-SeaSurf – An updated CSRF extension for Flask.
Flask-Admin – Simple and extensible admin interface framework for Flask
Flask-Security – Simple security for Flask apps
Flask – A microframework based on Werkzeug, Jinja2 and good intentions

Pip – Install a package

We can see that Flask is available.

Flask – A microframework based on Werkzeug, Jinja2 and good intentionsLet’s go ahead and install it

pip install Flask

Pip – Show information

Flask is installed, let’s show information about our newly installed packages.

pip show Flask

Name: Flask
Version: 0.10.1
Location: /usr/local/lib/python2.7/dist-packages
Requires: Werkzeug, Jinja2, itsdangerous

Pip – Uninstall a package

If you want to uninstall a package installed by PIP, you can do that as well.

pip uninstall Flask

Uninstalling Flask:
...
.....

Proceed (y/n)?

Successfully uninstalled Flask

Using pip is easy and with it you can easily install packages from Pypi.

Leave a Reply

Your email address will not be published. Required fields are marked *