How to create python2.7 virtualenv on Ubuntu 20.04

I want to run an application that uses python2.7 version, but by default python2.7 is not installed. When I tried to use:

$ virtualenv -p python2 flaskold

It returned:

RuntimeError: failed to find interpreter for Builtin discover of python_spec='python2'

How could I create python2.7 virtual environment on Ubuntu 20.04 which goes without python 2.7 support?


Install python2:

sudo apt install python2 virtualenv

Universe repository is being used for this. You could add it if not added the next way: $ sudo add-apt-repository universe.

Create virtual environment using python2.7 the next way:

$ virtualenv --python=$(which python2) /path/to/newenv/folder/

$(which python2) will return path to python2 which would be correct argument. python2 could be used to start interpreter in terminal, but could not be used as an argument value for --python directive