Update python on linux 2.7 to 3.5

Update python on linux 2.7 to 3.5

//install python 3.6

sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt update
sudo apt install python3.6

//change default python

sudo rm /usr/bin/python
sudo ln -s /usr/bin/python3 /usr/bin/python

//view default

 python -V

You still have Python 2 installed, and the python command is still set up to invoke that version by default.
Try running your scripts like this:

python3 yourscriptname.py

In /usr/bin/, python is actually a symlink to python2.7. If youd rather not have to type the 3 at the end whenever you use python, change that symlink to point to python3 instead. Then python will run Python 3.5 and you can use python2.7 or just python2 to run Python 2.7 scripts.

EDIT: Alternatively, you could put alias python=python3 in your ~/.bashrc file to do the same thing, but without needing root access and for your user account only.

Update python on linux 2.7 to 3.5

You might just have destroyed your system python installation by doing

sudo make install

This installs in the default path! And will possibly overwrite anything your linux distro has there to work correctly.
Never do sudo make installs if youre not sure where the resulting stuff goes.
In case of Python, you should have done

sudo make altinstall

to have it installed next to the default python but the best thing is to install and use the python version via your distros package manager.

Leave a Reply

Your email address will not be published. Required fields are marked *