For python, we can do it as follows on Linux and Unix:
First, if the python version you want to use has not been installed, install it. Then,
for Python3,
$python3 -m venv name_of_project
for Python2
$ virtualenv my_project
or to specify the version 2.X.X..
$ virtualenv -p /usr/bin/python2.7... name_of_project
("name_of_project" is the name that you are giving to the new folder that contains the virtual environment.)
Then,
$ source my_project/bin/activate
will start the virtual environment.
$ deactivate
will deactivate the current virtual environment.
$ pip freeze : to see the packages installed in the current virtual environment.
If you install packages using pip while being the virtual environment, they will be all installed and recorded together in the environment.