Home  >  Article  >  Backend Development  >  How to update Python version in Linux and modify python default version

How to update Python version in Linux and modify python default version

不言
不言Original
2018-04-04 16:32:033178browse

In many cases, the server python version obtained is very low, and you need to change the default python version yourself. However, many friends are stumped by this problem. Next, through this article, I will introduce to you how to update the Python version of Linux and Friends who are interested can learn how to modify the default version.

Update the Python version under Linux and modify the default version. Friends in need can refer to it.

In many cases, the server python version you get is very low, and you need to change the default python version yourself

1. Download python installation from the official website Package (this version can be any version 3.3 2.7 2.6, etc.)

wget http://python.org/ftp/python/2.7/Python-2.7.tar. bz2

2. Unzip and install

##

 tar -jxvf Python-2.7.tar.bz2 
cd Python-3.3.0 
./configure 
make all 
make install 
make clean

make distclean python default is installed in /usr/local/bin/python2.7, you can execute the following command to view the version

/usr/local/bin/python2.7 -V and the system’s default python is placed in /usr/bin /python2.6 (this 2.6 is the system default version)

Therefore, you need to establish a soft connection at this time to point to the current system default python directory, so that the system can use the new python version

mv / usr/bin/python /usr/bin/python2.6 //Operate the system default version of python

ln -s /usr/local/bin/python2.7 /usr/bin/python //Pay attention to the first one The path is the path of the newly installed python version, and the second path is the system default path
After the modification is completed, enter python -V or python to see that the version number has been modified to the newly installed version

PS:


1. If the new python version is modified, then the python plug-ins originally installed are not in the new version python directory, so you need to reinstall


2. Some people have updated the python version and cannot use yum. They need to modify its configuration file for yum


vi /usr/bin/yum Change the #!/usr/bin/python in the header of the file to # !/usr/bin/python2.6 (note that this is the previous version of python number, because the old version can only support yum at this time)


The above is the detailed content of How to update Python version in Linux and modify python default version. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn