After this lesson, you will be able to: Set up a professional Python environment with pyenv, virtual environments, pip, and the modern pyproject.toml.
Python's biggest beginner trap is environment management. Get this right once and the rest of the track flows.
This is a free introductory lesson. No purchase required.
Your laptop has one Python. Project A needs 3.10; Project B needs 3.12; the OS uses Python for itself. Mixing them = breaking things. Virtual environments isolate each project's dependencies. pyenv lets you install many Pythons side by side and pick per-project.
Install once; use forever.
# pyenv (macOS / Linux)brew install pyenv # or curl https://pyenv.run | bashpyenv install 3.12.4pyenv install 3.11.9pyenv global 3.12.4# Per-project: a .python-version file pins the versioncd my-project && pyenv local 3.12.4# Virtual environment (built-in)python -m venv .venvsource .venv/bin/activate # Linux/macOS.venv\Scripts\activate # Windowspip install requestsdeactivate# Modern alternative: uv (10x faster pip + venv replacement)curl -LsSf https://astral.sh/uv/install.sh | shuv venv && uv pip install requests
requirements.txt: a flat list of `package==version` lines. Old default; works everywhere. pyproject.toml (PEP 621): the modern standard. One file declares dependencies, dev-deps, build config, tool config. Lockfiles: pip-tools, poetry, or uv generate exact-version lockfiles for reproducible installs. Default for new projects in 2026: pyproject.toml + uv (or poetry).
Installing packages globally with `sudo pip install`. Eventually breaks the system Python. Skipping virtual envs. Every project pollutes the same shared site-packages. Pinning to no version OR exact patch version on every dep. Pin majors, let patches float, lockfile for reproducibility. Forgetting `.venv` in .gitignore.
Pick the cleanest answer.