A package groups modules under a directory (with __init__.py or namespace package rules). A venv is an isolated Python environment with its own site-packages—essential per-project dependency hygiene.
Layout example
myapp/
pyproject.toml
src/myapp/
__init__.py
main.py
Creating a venv (local)
python3 -m venv .venv
source .venv/bin/activate # macOS/Linux
pip install -r requirements.txt
The playground runs single files—practice full package layout on your machine before the Django track.
Important interview questions and answers
- Q: venv vs system Python?
A: venv isolates dependencies per project—avoids breaking system tools or other projects. - Q: __init__.py purpose?
A: Marks a directory as a package and can run package initialization code.
Self-check
- What command creates a venv?
- Why not pip install globally for every project?
Tip: One venv per project—python3 -m venv .venv before pip install.
Interview prep
- Why venv?
Isolates dependencies per project—Project A and B can require different Django versions.
- __init__.py role?
Marks package directory; can run package initialization on import.