Virtual Environment vs Version Manager
People think a virtual environment picks the Python version, and it does not. It keeps the packages of one project apart from the rest. A version manager picks which version of the language runs. Many projects use both: one for Python itself, one for its packages.
Virtual Environment
A folder for one project. It holds the Python code that project needs.
A virtual environment is a folder that holds the Python packages for one project. When it is on, what you install goes into that folder only. So two projects can use two versions of the same package, and both still work. You make one with python3 -m venv .venv, then turn it on before you install anything.
Version Manager
A tool that keeps a few versions of a language and lets you switch.
A version manager is a tool that keeps several versions of a language on one computer. It lets you switch between them, for each project or each terminal. nvm does this for Node.js and pyenv does it for Python. A small file in the project can name the version it needs. The manager then picks it for you.
In one line
- Virtual Environment
- A folder for one project. It holds the Python code that project needs.
- Version Manager
- A tool that keeps a few versions of a language and lets you switch.