Isolated Environments and Packages
Install a Package with pip
An empty environment is isolated, but it is not useful yet. Put one package inside it. If .venv is missing because the site saved and restored the chapter between visits, create it again first. That is expected: the environment is derived, while the small project files survive.
Activate .venv again if your prompt does not begin with (.venv), then run this in the site
source .venv/bin/activate
python -m pip install requests==2.34.2
This time the terminal has more to say. It names requests, downloads the exact version you asked for, finds the supporting packages that requests depends on, and installs them inside the active environment.
pip is Python’s package installer. We invoke it as python -m pip instead of relying on a bare pip command because that makes the pairing explicit: use the installer belonging to this python. When several Python installations exist, that small habit prevents a great deal of confusion.
Read the request precisely
The text requests==2.34.2 contains a package name and an exact version pin. The double equals means “install this version,” not merely “install something recent enough.” Exact pins make the rehearsal repeatable. Everyone in this course gets the package behavior the lesson was written against.
Ask pip what it installed:
python -m pip show requests
Look for these two lines in the result:
Name: requests
Version: 2.34.2
Make Python use it
Installer output is not the finish line. A package is useful when Python can import it. Open a small file with nano check_package.py and enter these two lines:
import requests
print(requests.__version__)
Save and leave nano, then run the file:
python check_package.py
It should print 2.34.2. import requests makes the installed package available to this program, and requests.__version__ reports the release that actually loaded. We are not making an HTTP request yet. That belongs much later, when failures and timeouts have somewhere to be taught properly.
The same command, a different shelf
On the Python Land site, pip uses a small first-party package requests==2.34.2, pytest==9.1.1, and uv==0.12.3, plus the exact supporting packages they need. Learner code cannot fall through to the public internet.
On your own computer, ordinary pip uses the public check_package.py in your local practice directory before running the final command.
source .venv/bin/activate
python -m pip install requests==2.34.2
python -m pip show requests
python check_package.py
.\.venv\Scripts\Activate.ps1
python -m pip install requests==2.34.2
python -m pip show requests
python check_package.py
If activation is blocked, use the environment’s Python explicitly for every remaining command:
.\.venv\Scripts\python.exe -m pip install requests==2.34.2
.\.venv\Scripts\python.exe -m pip show requests
.\.venv\Scripts\python.exe check_package.py
source .venv/bin/activate
python -m pip install requests==2.34.2
python -m pip show requests
python check_package.py
Why does this course use python -m pip?
You now know the success path. The failure message is just as important, because it tells you whether to fix a name or wait for a service.