virtualenv is a tool to create isolated Python environments. virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need.
$ pip install virtualenv
$ virtualenv -p python3 venv
Once the virtual env is created, it will create a directory with the name used to create the virtualenv. This directory structure will contain bin, include, lib directories.
Just creating the virtualenv will not activate the environment. There are explicit commands to activate and deactivate the virtual environment. Once activated the pip commands will work in context to the virtual environment created, unless deactivated
$ source venv/bin/activate
$ pip list
This virtual env comes with bare minimum packages, displayed in the screenshot below
You may now procced to install packages which you need in virtualenv.
$ pip install requests
Once, requests is installed, running the command pip list now lists the specific dependency set requirements for the virtual environment
Using the pip freeze command we can generate a requirements.txt file to list out the dependencies required for executing the python app in concern. This file may be committed to the repository for other devs/ machine to setup similar env
$ pip freeze --local > requirements.txt
$ pip install -r requirements.txt
$ deactivate