0Pricing
Python Academy · Lesson

Managing Dependencies with pip

Install packages, pin versions, and use requirements.txt.

Managing Dependencies with pip is a free Python Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Python Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Introduction

Effective dependency management means pinning versions, separating dev dependencies, and keeping requirements up to date.

pip install Basics

pip install package installs the latest version. pip install package==1.2.3 pins to exact version.
# pip install requests
# pip install requests==2.31.0
# pip install 'requests>=2.25,<3'
print('install demo')

pip freeze

pip freeze outputs all installed packages with exact versions. Redirect to requirements.txt for reproducibility.
# pip freeze > requirements.txt
# Contents like:
# requests==2.31.0
# urllib3==2.0.4
print('freeze demo')

pip install -r

pip install -r requirements.txt installs all listed packages at their pinned versions.
# pip install -r requirements.txt
# Installs exactly what freeze captured
print('install -r demo')

Dev vs Prod Dependencies

Keep separate files: requirements.txt (production), requirements-dev.txt (testing, linting).
# requirements.txt:
# requests==2.31.0
# requirements-dev.txt:
# pytest==7.4.0
# black==23.7.0
print('separate deps demo')

pip show

pip show requests shows version, location, and dependencies of an installed package.
# pip show requests
# Output:
# Name: requests
# Version: 2.31.0
# Requires: certifi, charset-normalizer, idna, urllib3
print('show demo')

pip list --outdated

pip list --outdated shows all packages with newer versions available.
# pip list --outdated
# Package  Version  Latest  Type
# requests 2.28.0   2.31.0  wheel
print('outdated demo')

Pinning Strategies

== pins exact. >= sets minimum. ~= allows compatible releases. * For security, pin exact versions in production.
# Production: pin exact
# requests==2.31.0
# Development: allow compatible
# requests~=2.31
print('pinning strategy')

pip check

pip check verifies no conflicting or missing dependencies in the current environment.
# pip check
# No broken requirements found.
print('check demo')

Editable Installs

pip install -e . installs your package so that changes to the source are immediately reflected.
# In your project root with pyproject.toml:
# pip install -e .
# Now changes to src/ are live
print('editable demo')

pip-audit for Security

pip-audit checks installed packages against the PyPI Advisory Database for known vulnerabilities.
# pip install pip-audit
# pip-audit
# No known vulnerabilities found.
print('audit demo')

Quick Check

What does pip freeze > requirements.txt do?

Recap

pip install (latest/pinned), freeze (snapshot), install -r (restore), show (info), list --outdated, check (conflicts). Separate prod/dev requirements files.

Keep Going

Keep it up! Move on to the next lesson.

Frequently asked questions

Is the “Managing Dependencies with pip” lesson free?

Yes — the full text of “Managing Dependencies with pip” is free to read here on the web, and the Python Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Python Academy course, upgrade to CoddyKit PRO.

What will I learn in “Managing Dependencies with pip”?

Install packages, pin versions, and use requirements.txt. You practise Python Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Python Academy?

No prior experience is required. Python Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Managing Dependencies with pip” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Python Academy lesson?

Yes. Every Python Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Why Virtual Environments Matter
  2. Creating and Activating venv
  3. Managing Dependencies with pip
  4. Modern Tools: pipenv and uv
← Back to Python Academy