Skip to main content
One of Python’s greatest strengths is the enormous ecosystem of open-source packages available for almost every task imaginable. Instead of writing complex code from scratch to download web data, process spreadsheets, or call an AI API, you can install a package written and maintained by other developers and use it in your project immediately. Understanding how to manage these packages with pip is one of the most practical skills you will use every day as a Python developer.

What are packages?

Packages are collections of Python code organised to solve specific problems. They are distributed through PyPI — the Python Package Index — which hosts over 500,000 packages. Some packages you will use frequently in this course:

Meet pip

pip (Pip Installs Packages) is Python’s built-in package manager. It comes with Python and is already available inside your virtual environment. It handles downloading packages from PyPI, installing them, resolving their dependencies, and managing versions.
When you activate your virtual environment, you get a dedicated copy of pip that installs packages only into that environment. Packages installed here do not affect any other project or your system Python.

Install your first package

1

Open the VS Code terminal

Press Ctrl + ` (Windows/Linux) or Cmd + ` (macOS). Confirm you see (.venv) at the start of the prompt — this means your virtual environment is active.
2

Install a package

You will see output like:
3

Use it in your code

Notice that installing requests also installed packages like certifi, charset-normalizer, and urllib3. These are dependencies — packages that requests itself relies on. pip resolves and installs the full dependency tree automatically.
To see the actual files that were installed, look inside .venv/lib/python3.x/site-packages/requests/ — it is just Python files that someone else wrote and shared.

Common pip commands

Managing dependencies with requirements.txt

When you share your project with others (or deploy it to a server), they need to know which packages to install and which versions you used. A requirements.txt file captures this information. Generate a requirements file:
The file looks like this:
Install from a requirements file:
This is the standard way to reproduce an environment — on a new machine, in a team, or in a CI/CD pipeline. Anyone with your requirements.txt can recreate an identical environment with a single command.
Commit your requirements.txt to version control (Git) so your teammates and future deployments always have a record of the exact package versions your project depends on.

Troubleshooting

Your virtual environment is probably not active. Check whether (.venv) appears in your terminal prompt. If not, select your interpreter in VS Code via Ctrl/Cmd + Shift + PPython: Select Interpreter.
You are probably trying to install into system Python rather than your virtual environment. Never use sudo pip install. Always confirm (.venv) is visible in your prompt before installing.
Package names on PyPI can differ from what you might expect:
  • “Beautiful Soup” → pip install beautifulsoup4
  • “OpenAI” → pip install openai
  • “Pillow (PIL)” → pip install pillow
Search pypi.org for the exact package name if you are unsure.
If pip reports a conflict between package versions, the cleanest solution is to create a fresh virtual environment and reinstall only what your project needs. This is exactly why you use one virtual environment per project.

Interactive Python

Learn how to run Python interactively from a .py file using Shift + Enter.