Saturday, February 15, 2020

pip in Python

PIP In Python


PIP is a package manager for Python packages and modules. It is the most commonly used package manager for the Python Package Index; PIP is available by default with latest versions of Python (version above 3.4 or later)

What is a package?

A package is a container for all the files required for a module to function. These modules are basically libraries of Python that you may need to complement your program.

Do you have pip?

If you do not have a pip installation than you can download and install it by using this link.

You can also upgrade pip installed in your machine using pip command itself

$ pip install - -upgrade pip

You can install the latest version of a package named pack using pip very easily by pip commands:

$ pip install pack

You can also install a specific version of a package:

$ pip install pack==2.1.4

You can also describe a minimum version to be installed:

$ pip install pack>=2.1.3

You can use sudo with the commands If the permission is denied error is prompted on Linux/Unix.

Once you have installed the package you can check it using freeze command:

$ pip freeze

To list all the packages installed you can use the list command

$ pip list

The output will be something like

docutils (0.9.1) 
Jinja2 (2.6)
Pygments (1.5)
Sphinx (1.1.2)

You can also list outdated packages using the command

$ pip list - -outdated

An already installed package can also be updated using the upgrade command

$ pip install - -upgrade pack

You can use uninstall command to uninstall some package

$ pip uninstall pack

We can use import keyword to use any installed package

import camelcase   #use import to import some package
c = camelcase.CamelCase()
txt = "hello world"