Skip to content

Installing Python Packages

chuckablack edited this page Nov 17, 2020 · 3 revisions

Overview

One of the nice things about Python is, as they say, "everything is included". Which means that there are a ton of open source projects out there, that have been written to do just about everything you want done with Python. These add-on libraries (also called open source "projects" or "modules" or "packages") don't come with Python by default, but they must be added.

The way you install these libraries is using "pip", which stands for "Pip Installs Packages", which is recursive, self-referential, etc., but you get the idea. You also get the idea that the things it installs are technically "packages", although in common language people loosely refer to them as "libraries" (as they are called in other languages).

General installation

In general you will be using pip to install packages, as needed. You do this using the pip command. Since we are using Python version 3, everything tends to have a "3" suffix, e.g. we run Python with the python3, and similarly, we run pip using the pip3 command.

For example, one of the early lessons uses a package called "tabulate". The way to install this, in Linux, from a terminal window:

$ pip3 install tabulate

Sometimes, packages we install require superuser privileges, since they modify some code that requires that level of access. In these situations, for Linux, we use the 'sudo' command:

$ sudo pip3 install tabulate

Depending on your OS, this may be different. With software, google will be your best friend - if you google what you are looking for, quite often it will take you to pages that explain how to do exactly what you are looking for.

Clone this wiki locally