LESSON · 1 OF 5

pip and PyPI

pip and PyPI

The standard library is broad, but it doesn't cover everything. When you need something like requests for HTTP or boto3 for AWS, you install it with pip. pip is Python's package installer, and it pulls from PyPI, the public index where the Python community publishes libraries.

Installing a package

The basic command names the package you want:

bash
pip install requests

pip contacts PyPI, downloads requests and anything it depends on, and puts them where your Python can import them. After that, import requests works in your code.

Seeing what's installed

Two commands tell you what's already there:

bash
pip list
pip show requests

pip list prints every installed package and its version. pip show gives details about one package, including its version and what it depends on.

Dependencies come along

Most packages rely on other packages. requests alone pulls in a handful of supporting libraries for URLs and certificates. pip resolves that whole tree for you and installs everything needed, which is the main reason you never copy library files by hand.

A quick note on where it installs

Where a package lands depends on whether a virtual environment is active. Inside an active venv, pip install drops the package into that venv. Outside one, it targets the system or user Python. The next nodes tie pip together with venvs and a requirements file so installs are both isolated and repeatable.

What this node covers

  • pip install name downloads a package and its dependencies from PyPI.
  • pip list shows installed packages; pip show name details one.
  • pip resolves and installs a package's dependencies for you.
Spin up a fresh environment and practice live.
python-devops · fresh machine · ready in under a minute