Installing python packages with pip and virtualenv

Overview

Teaching: 45 min
Exercises: 15 min
Questions
  • Key question

Objectives
  • First objective.

pip

pip is a package manager for python packages. You can install software locally using your home folder to store it.

Installing packages

The basic command to install packages is

$ pip install --user PACKAGE_NAME

However, pip allow you to do much more, you can for example install packages with specific versions

pip install PACKAGE_NAME            # latest version
pip install PACKAGE_NAME==1.0.4     # specific version
pip install 'PACKAGE_NAME>=1.0.4'     # minimum version

Listing

To list just the packages you have installed locally execute:

pip list --user

You can also see the packages outdated

pip list --user --outdated

Show details about packages

pip show scipy

Uninstalling

pip uninstall PACKAGE_NAME

virtualenv

virtualenv is a tool to create isolated Python environments. You can use virtualenv to control the libraries needed by one application. If an application works, any change in its libraries or the versions of those libraries can break the application.

The use is very simple. First you need to create the environment.

$ virtualenv ENV

To activate it use:

$ source bin/activate

To deactivate the environment, just use

$ deactivate

Key Points

  • First key point.