A virtual environment is created on top of an existing Python installation, known as the virtual environment’s “base” Python. It may optionally be isolated from the packages in the base environment, so only those explicitly installed in the virtual environment are available.
A virtual environment is
- Used to contain a specific Python interpreter and software libraries and binaries that are needed to support a project (library or application). These are by default isolated from software in other virtual environments and Python interpreters and libraries installed in the operating system.
- Contained a directory, conventionally either named venv or .venv in the project directory, or under a container directory for lots of virtual environments, such as ~/.virtualenvs.
- Not checked into source control systems such as Git.
- Considered as disposable – it should be simple to delete and recreate it from scratch. You don’t place any project code in the environment.
- Not considered as movable or copyable – you just recreate the same environment in the target location.
Running this command creates the target directory
python -m venv /path/to/new/virtual/environment
Command to activate virtual environment
$ source <venv>/bin/activate
Reference: https://docs.python.org/3/library/venv.html