# Python Level 5: Modules & Packages

> Level 5: Modules & Packages of the LoWisa Python course: Modules and Imports, Packages and Project Structure, Virtual Environments and Dependencies. 3 lessons and 9 ideas, each explained in one line.

Modules & Packages is level 5 of 17 of the [LoWisa Python course](/courses/python/). It has 3 lessons and 9 ideas. Below is every lesson and what it teaches, in one line each.

## Modules and Imports

- **Modules.** Every .py file is a **module** with its own namespace: import runs it once and caches the result.
- **Import forms.** import math keeps the namespace; from math import **sqrt** pulls one name in directly: both have their place.
- **__name__.** The **__name__** variable equals "__main__" only when the file is run directly: the guard that keeps imports side-effect free.

## Packages and Project Structure

- **Packages.** A **package** is a directory of modules with an __init__.py, letting imports nest: from shop.orders import checkout.
- **Project layout.** A healthy project separates **src** code, tests and configuration: tooling and imports both rely on that shape.
- **Absolute imports.** Prefer **absolute** imports naming the full package path: relative dots break the moment files move.

## Virtual Environments and Dependencies

- **Virtual environments.** A **virtual** environment gives each project its own installed packages, so two projects never fight over versions.
- **pip and requirements.** **pip** installs packages from PyPI, and a pinned requirements file makes the same install reproducible anywhere.
- **Dependency hygiene.** Every dependency is code you now ship: pin **versions**, audit what you add, and prune what you stopped using.

## Before and after this level

- **Before:** [Level 4: Functions & Scope](/courses/python/level-4-functions-and-scope/): Functions, Parameters and Returns, Scope and Name Resolution, Functional Patterns and Lambdas.
- **Next:** [Level 6: Object-Oriented Python](/courses/python/level-6-object-oriented-python/): Classes and Objects, Inheritance, Composition and Protocols, Dataclasses and Domain Models.

In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See [Checkpoints and flashcards](/help/checkpoints-and-flashcards/).

## Frequently asked questions

### What does Python Level 5: Modules & Packages cover?

Modules and Imports, Packages and Project Structure, Virtual Environments and Dependencies: 3 lessons and 9 ideas.

### What should I know before this level?

The level before it, Level 4: Functions & Scope, which covers Functions, Parameters and Returns, Scope and Name Resolution, Functional Patterns and Lambdas.

## Learn Python on your phone

The first level is free. LoWisa is on Google Play and the App Store.

---

Source: https://lowisa.dev/courses/python/level-5-modules-and-packages/ · Updated 2026-11-16
