Reference: https://www.cnblogs.com/wmr95/p/7637077.html
Under normal circumstances, ubuntu16.04 will automatically install the python2.7 version, here I try to upgrade it to python3.5 version
One: Open the terminal of ubuntu and enter the command on the command line:
python
The display is as follows, indicating that the python version that comes with the system is python2.7.12
Two: Enter the command on the command line:
sudo apt-get install python3 (install python3.5 here, the command is: sudo apt-get install python3.5)
After entering your password, it will download. The Python program just downloaded is installed in usr/localb/python3.5.
Three: Specify the python3.5 version (your newly installed python version) to be opened by default.
After the installation is complete, you enter python in the terminal, and the output information will prompt that it is version 2.7, which means that the default version is not the 3.5 installed just now, so we need to modify the link again. Methods as below:
Step 1: Back up the original link first (it is a good habit to back up before deleting the system). Enter the command under ternimal:
sudo cp /usr/bin/python /usr/bin/python_bak
Step 2: Delete the link that originally pointed to the python2.7 version by default. Enter the command under ternimal:
sudo rm /usr/bin/python
Step 3: Re-assign the new link to python3.5 version. input the command:
sudo ln -s /usr/bin/python3.5 /usr/bin/python
At this point, the python version update has been completed.
Note: Switch between python2.7 and 3.5 at will (here 3.5 switches back to 2.7):
sudo rm /usr/bin/python
sudo ln -s /usr/bin/python2.7 /usr/bin/python
Recommended Posts