Why does every Python project need its own virtual environment instead of installing packages globally?
Answer
A virtual environment, created with `python -m venv .venv`, gives a project its own isolated Python interpreter and `site-packages` directory, so its dependencies and their exact versions do not conflict with another project's dependencies or with packages installed system-wide. Without isolation, two projects that need incompatible versions of the same library cannot both work on one machine, and upgrading a dependency for one project risks silently breaking an unrelated one that happened to share the global environment.
Strong answer includes
- venv creates an isolated interpreter and site-packages per project
- avoids version conflicts between unrelated projects
- without it, upgrading a shared global dependency can break other projects
Practical example
Project A needs
requests==2.20and project B needs
requests==2.32; without separate virtual environments, installing one version globally breaks whichever project needed the other.