Install uninstall and manage Python packages with pip

 

Introduction

The power of Python is the very large amount of libraries that are available online. These libraries can be downloaded to your development environment as packages. Libraries installed on your system system are gradually accumulating and their management could be problematic if there were no adequate tools.

The package management in Python can be really an easy thing if you use the right tools and Pip is one of them.

Pip and PyPI – the Python Package Index

Tutti i pacchetti più utilizzati dalla comunità di sviluppatori in Python vengono raccolti da anni in un repository unico e mondiale chiamato In questo repository, tutti i pacchetti vengono ordinati, documentati e versionati con un opportuno controllo per le dipendenze.

All the packages used by the community of developers in Python are collected for years in a single repository called PyPI (Python Package Index). In this repository, all packages are sorted, documented and versioned with a suitable control for all dependencies.

PIP is an essential tool that allows you to download, update (synchronize virtually) all of the repository packages you need, taking care to check the proper dependencies and the compatibility among versions

Pip installation

Generally in most distributions of Python, pip should already be included. In fact, for all versions of Python 2> 2.7.9 and Python 3> 3.4, pip is already installed. Same thing if you have created a virtual environment with virtualenv or pyenv.

Installation is simple

On Ubuntu and Debian

On Fedora

On Mac

But if it were not so, you can install it by downloading a script in Python specially created and then run it.

Using PIP – Commands

Pips, in addition to being very useful, it is also very simple to use. From the command line, Just write pip followed by an option (command) which is nothing but the task that we want him to do.

Installing a package

For example, to install a package, simply write

Pip will connect with the repository, then perform a search to find the package you requested. It will check if there is a version compatible with your version of Python and with the operating system you are using.

Then it will ask you for confirmation if you want to install with classic choice Yes or No. Then if confirm the installation will begin to install the package and any other packages which are required for its operation.

Uninstall a package

Removing a package is even easier

List installed packages

To get the list of installed packages on your system

or

Search for a particular package in the repository PyPI

Finally if you want to know both the existence and the information of a given packet within the PyPI repository without having to install it, you write the following command:

update PIP

However Python is a language that is experiencing great excitement and then every month there are always a number of new releases, including PIP. So it is important to check if PIP itself is upgraded to the latest version

To update PIP simply write

and the system will begin to write the following commands

Once you have updated PIP, you’ll know which packages have newer versions than those currently installed on your system

You will get a table with the name of a package, the current version installed on your system and the latest version in the repository

Update all packages or packages with a single command

it is strange but true, there is no simple and direct command to update all packages that we have installed on our system. So?

Well there is a fairly complex line with a pipe of different commands that allows you to do this:

and the system will begin to update a package after the other. This may take several minutes.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.