Lesson 15: Working with External Libraries (pip)

How to install, manage, and use third‑party Python packages

What Is pip?

pip is Python’s package installer. It allows you to download and install external libraries from the Python Package Index (PyPI), giving your projects access to thousands of tools and extensions.

Checking pip Installation

pip --version

Installing a Package

To install a package from PyPI:

pip install requests

Using the Installed Package

import requests

response = requests.get("https://api.github.com")
print(response.status_code)

Upgrading a Package

pip install --upgrade requests

Uninstalling a Package

pip uninstall requests

Searching for Packages

You can search PyPI directly:

pip search flask

Listing Installed Packages

pip list

Using requirements.txt

Export all installed packages:

pip freeze > requirements.txt

Install packages from a requirements file:

pip install -r requirements.txt

Installing Specific Versions

pip install django==4.0

Installing from GitHub

pip install git+https://github.com/user/repo.git

Why External Libraries Matter

Popular Python Libraries

Next Steps

Now that you know how to install and use external libraries, you're ready to explore APIs and web requests in Lesson 16: Introduction to APIs and HTTP Requests.

← Back to Lesson Index