How to install, manage, and use third‑party Python packages
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.
pip --version
To install a package from PyPI:
pip install requests
import requests
response = requests.get("https://api.github.com")
print(response.status_code)
pip install --upgrade requests
pip uninstall requests
You can search PyPI directly:
pip search flask
pip list
Export all installed packages:
pip freeze > requirements.txt
Install packages from a requirements file:
pip install -r requirements.txt
pip install django==4.0
pip install git+https://github.com/user/repo.git
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