Home > Article > Backend Development > How to install python in Ubuntu
Ubuntu16.04 has Python2.7 and 3.5 installed by default
Please note that the python that comes with the system must not be uninstalled!
Enter the command python
Press Ctrl D to exit the python command line
Enter the command sudo add -apt-repository ppa:jonathonf/python-3.6
Press Enter to confirm
Enter the command sudo apt-get update
Enter the command sudo apt-get install python3.6
Press Y to confirm
Adjust the priority of Python3 so that 3.6 has a higher priority
sudo update-alternatives --install /usr /bin/python3 python3 /usr/bin/python3.5 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
Change The default value, python defaults to Python2, is now modified to Python3
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives - -install /usr/bin/python python /usr/bin/python3 150
At this time, enter the command python
You can see that it is already Python3.6
For more Python-related technical articles, please visit the Python Tutorial column to learn!
The above is the detailed content of How to install python in Ubuntu. For more information, please follow other related articles on the PHP Chinese website!