How to modify the python version in the Linux environment compilation server

1. System level modification

1. Use whereis python to view the python version existing in the server

2. Delete the original python version environment

sudo rm /usr/bin/python

3. Switch python version

ln -s /usr/bin/python3.6 /usr/bin/python

4. Check the python version

python --version

2. User level modification

1. Check whether there are the following two hidden files in the home/username directory

If there are no above two files, copy the two files .bashrc and .profile from the /etc/skel/ directory to the home/username directory, which is the screenshot directory above

2. Create a new bin directory in the home/username directory and link the python version

Link versions via ln -s, for example:

ln -s /usr/bin/python2.7 python2.7

3. Switch the python version

Delete the python directory under the bin directory and relink

If the current python version of the blogger is python2.7, if you want to change to version 3.8, follow the steps below:

rm python

ln -s python3.8 python

4. Make the environment work

source  .profile

Remarks: The following method of modifying the python version at the user level is also said on the Internet. The blogger verifies that the python version has changed after the modification, but when compiling the Android system code, an error is reported, which seems to be caused by the python version not really taking effect.

vim ~/.bashrc
添加 alias python='/usr/bin/python2.7'
source ~/.bashrc

Guess you like

Origin blog.csdn.net/banzhuantuqiang/article/details/130929438