- All Courses
- Python Foundations for Data Work
- Python Essentials
- Modules, packages, and virtual environments
Modules, packages, and virtual environments
Installing packages globally means every project shares one set of versions, and the first version conflict breaks something you were not working on.
Overview
One environment per project, always
Installing packages globally means every project shares one set of versions, and the first version conflict breaks something you were not working on. A virtual environment gives each project its own isolated set.
A module is just a file, and a package a directory of them. The import guard that checks whether a file is being run directly is what lets the same file work as both a script and an importable module.
Record your dependencies in a file and pin versions for anything you will run again. An unpinned environment reproduces differently every month.
In this lesson you will:
- Split a script into importable modules
- Isolate dependencies per project
- Pin what you installed so it reproduces
Resources
Notes are not saved yet — they clear when you leave this page.
Functions, arguments, and scope
15m
Lists, tuples, and slicing
15m