This article describes the method of installing python in the ubuntu server environment. Share with you for your reference, as follows:
The ubuntu 14.04-16.04 version installs python 2.7 by default
1、 View current python version
$python --version
2、 Upgrade to python3.X version
$sudo add-apt-repository ppa:fkrull/deadsnakes#Add a source
$sudo apt-get update#Update the source list to get the latest version
$sudo apt-get install python3#Use apt-get to install
3、 After the installation is complete, there are two options for changing the system environment.
① Situation 1:
Use alias alias, add the following statement to ~/.bashrc or ~/.bash_aliases
alias python=python3
Note: switch back to python2 environment
alias python=python2
② Case two, directly change the direction of the version:
(1) Check the current default execution environment version, if this item does not include python, you can skip it.
android@local:/usr/local/bin$ls
apktoolpython
(2) Delete the current default python environment script
android@local:/usr/local/bin$ sudo rm /usr/local/bin/python
android@local:/usr/local/bin$ ls
apktool apktool.jar
(3) View the installed python version contained in the /usr/bin/ path.
ls /usr/bin/
(4) Switch to the version below /usr/bin/
android@local:/usr/local/bin$sudo ln -s /usr/bin/python3 /usr/local/bin/python
Note: switch back to python2 environment
android@local:/usr/local/bin$sudo
ln -s /usr/bin/python2 /usr/local/bin/python
**Other situations: **
If you encounter other problems and need to be fixed, just download it again:
sudo apt-get
install --reinstall python-minimal
sudo apt-get
install --reinstall python2.7
I hope this article will help you configure your Ubuntu server.
Recommended Posts