Ubuntu – Python2.7 not working in 18.04, python3 is installed

18.04pythonvirtualbox

I have installed ubuntu 18.04 in virtual box and when trying python -v, it says you have python3 installed, I want to remove python 3 or disable so that can use python2.7 and run some scripts i have.

Best Answer

Python 2 is no longer installed by default in fresh installations of Ubuntu 18.04 and later. Don't remove python3 from Ubuntu 18.04 and later or else Ubuntu Software, the terminal and many other apps that are installed by default will stop working. If you removed Python 3 and now Ubuntu Software, terminal and other applications don't work follow the instructions in this answer to reinstall it and get all applications working again.

To install Python 2.7 in Ubuntu 18.04 and later open the terminal and type:

sudo apt install python2.7  

To start the Python 2.7 interpreter run this command:

python2.7

To start the Python 3 interpreter run this command:

python3  

Either way the Python interpreter will show a version message when it is started that shows what version of Python you are running.

Related Question