core Estimated learning time: 4 h

2.14 Modules, packaging and environments

You can hand someone a repo that installs and runs.

Before:00. Orientation & SetupUnlocks:03. Data Handling & Analysis04. Classical AI — Agents, Search & Knowledge Representation

Packaging turns works-on-my-machine into pip-install-and-run: pyproject.toml, package layout, and lockfiles that make builds repeatable. Understanding imports properly also dissolves most mysterious ImportErrors. It sits late in the module because it packages what the earlier topics built. The trap is the unpinned dependency — without a lockfile the same repository builds differently on different days, and the difference always surfaces at the worst time.

Work through these

  • Imports, packages, __init__.py, relative imports

    How Python finds code across files and directories, and the difference between the two ways of writing an import. Import errors are among the most common early frustrations, and they come from here.

  • pyproject.toml and building a package

    The standard project description file and what it takes to build an installable package. Doing this once demystifies every library you install.

  • uv / poetry / pip-tools and lockfiles

    The current tools for managing dependencies and recording exact versions so an install is repeatable. A lock file is what makes it work on somebody else's machine.

  • Publishing to PyPI once, to understand it

    Publishing a package to the public index once, to see the whole path from your directory to somebody else installing it. Understanding the process matters more than the package.

Sign in to keep your progress.

Free resources

Links last checked 29 Aug 2026.

Stuck here?

Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.

Checking your session…

Topics shown in module order.