Method to install python in ubuntu server environment
- 2020-10-31 22:03:27
- OfStack
This article illustrates how to install python in an ubuntu server environment. To share for your reference, the details are as follows:
ubuntu 14.04 --16.04 is installed as python 2.7 by default
1. View the current version of python
$python --version
2. Upgrade to python3.ES14en version
$sudo add-apt-repository ppa:fkrull/deadsnakes # add 1 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 the
3. After the completion of installation, there are two solutions to change the system environment.
Situation 1:
Using the alias alias, add the following statements to ~/.bashrc or ~/.bash_aliases
alias python=python3
Note: Change back to python2
alias python=python2
Situation 2, directly change the version to point to:
(1) View the current default version of the execution environment. If this 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 version of python included under the /usr/bin/ path.
ls /usr/bin/
(4) Switch the pointing of /usr/bin/ version below
android@local:/usr/local/bin$sudo ln -s /usr/bin/python3 /usr/local/bin/python
Note: Change back to python2
android@local:/usr/local/bin$sudo
ln -s /usr/bin/python2 /usr/local/bin/python
Other information:
If you encounter other problems and need to fix them, just download 1 again:
sudo apt-get
install --reinstall python-minimal
sudo apt-get
install --reinstall python2.7
Hopefully, this article has helped you with your Ubuntu server configuration.