make: flex: Command not found

Try this:

Open a terminal,

Press Ctrl+Alt+T

Run it:

sudo -i
nano /etc/apt/sources.list

In the open file, delete its contents and put this:

deb http://old-releases.ubuntu.com/ubuntu/ utopic main restricted
deb-src http://old-releases.ubuntu.com/ubuntu/ utopic main restricted
deb http://old-releases.ubuntu.com/ubuntu/ utopic-updates main restricted
deb-src http://old-releases.ubuntu.com/ubuntu/ utopic-updates main restricted
deb http://old-releases.ubuntu.com/ubuntu/ utopic universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ utopic universe multiverse
deb http://old-releases.ubuntu.com/ubuntu utopic-security main restricted
deb-src http://old-releases.ubuntu.com/ubuntu utopic-security main restricted
deb http://old-releases.ubuntu.com/ubuntu/ utopic-backports main restricted universe multiverse

Ctrl+O Save File

Ctrl+X Close Nano

Continue running:

apt-get update
apt-get dist-upgrade
apt-get install flex