Skip to main content
In this lesson, you’ll learn how to install and manage external packages from the Python community using the centralized Python Package Index (PyPI). Maintained by the Packaging Working Group, PyPI is the primary repository for Python packages and is completely free, allowing you to install and use any available code.

Accessing PyPI with pip

To work with PyPI packages, you need to use a tool called pip. Before installing packages, make sure that pip is installed or upgraded. Some Python installations include pip by default, while others require manual installation. You can upgrade pip using the following command:
You can verify that pip is installed by checking its version:
For instance, the output might be similar to:
A working network connection is required since pip downloads packages over the internet.

Searching and Installing Packages

You can search for packages either directly on the PyPI website or via the pip search command in your terminal. Once you find a package you want to use, you can install it using the pip install command. For example, let’s install the popular community package Pygame. After installation, you can retrieve more details about the package (such as its version, description, author, and dependencies) using the pip show command:

Specifying Package Versions and Uninstalling Packages

With pip, you can also install a specific version of a package by appending == and the desired version number to the package name. For example, to install version 2.0.1 of Pygame, run:
If you no longer require a package, you can easily remove it using the following command:
Replace <package-name> with the name of the package you wish to uninstall. That’s it for now! It’s time to gain some hands-on experience with installing and managing Python packages from PyPI. Happy coding!

Watch Video

Practice Lab