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
3
Use it in your code
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.
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. Arequirements.txt file captures this information.
Generate a requirements file:
requirements.txt can recreate an identical environment with a single command.
Troubleshooting
pip: command not found
pip: command not found
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 + P → Python: Select Interpreter.Permission denied
Permission denied
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 not found
Package not found
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
Version conflict errors
Version conflict errors
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.