Introduction to Python Environments
A Python environment combines an interpreter with the packages available to it. Keeping one environment per project prevents an upgrade for one project from silently changing another.
What isolation does
A virtual environment has its own Python executable and package-installation directory. It does not fully isolate operating-system libraries, environment variables, credentials, files, or network access. Containers and remote services solve different, broader isolation problems.
Common choices
venvplus pip is the standard-library path for lightweight Python projects.- Conda manages Python and non-Python packages and is common in scientific computing.
- Containers package an application with more of its operating-system environment, at the cost of additional complexity.
- Jupyter is an interactive interface, not an environment manager. A notebook runs through a kernel that belongs to some environment.
Do not layer these tools accidentally. Decide which tool owns the environment, then use that environment's interpreter to install and run packages.
A reliable project loop
- Create a project directory.
- Create an isolated environment inside or associated with it.
- Activate the environment or invoke its interpreter explicitly.
- Install declared dependencies.
- Record direct dependencies and the Python version the project supports.
- Recreate the environment periodically to prove the declaration is complete.
The next lessons show this workflow with venv, pip, requirements files, Conda, and Jupyter.