CentOS 6 is a relatively stable version of Linux server that has been running for many years in production environments in a number of enterprises. However, the original version of Python in CentOS 6 is still 2.6, and is typically developed using python2.7 during development. python2.7 is the last 2.x version supported by Python, and it is a full and stable version of the feature. Most developers who do not turn to Python3 now use the python2.7 version.
Because old python in CentOS has been deeply dependent on the system, uninstalling the original Python will cause some software anomalies in the system, so it cannot be uninstalled. What if you want to use a different version of Python? The best way is to install a new version.
This article briefly summarizes the process of upgrading the python2.6.6 version to 2.7.14 in CentOS6.8.
Download Python source code.
Address: https://www.python.org/downloads/release/python-2714/
Unzip and install.
TAR-ZXVF python-2.7.14.tar.gz
CD Python-2.7.14
./configure--prefix=/usr/local/python2.7
Make
Make install
If there is no error in the previous step, you can enter this step to create a python executable file soft link. If you don't want to overwrite the Python executable file of the original python2.6, you can create a soft link called python2.6, and then create a soft link for the python2.7.
Ln-s/usr/local/python2.7/bin/python2.7//usr/bin/python
Now you can look at the Python version.
Python-v
- Since the Yum tool in CentOS uses python2.6 and can only use it, when we modify the default interpreter for the Python command, Python is redirected to python2.7. Yum is then used to give an error, so the Yum Python interpreter is specifically designated as python2.6.
Vim/usr/bin/yum
Modify the "#!/usr/bin/python" of the first line to the original Python version location of the system:
#!/usr/bin/python2.6
CentOS 6 upgrade Default Python version