Update Python to the latest version in CentOS.
Note: Do not delete old python versions when updating python! New and old versions can coexist. Many basic commands and software packages must depend on the pre-installed old version of python, such as yum.
Update python:
Step 2: Update gcc. If the gcc version is too old, the new python package cannot be compiled.
[Plain] view plaincopy
- # Yum-yinstallgcc
Step 2: Download the Python-2nd package [plain] view plaincopy
- # Wgethttp: // python.org/ftp/python/3.4.3/Python-3.4.3.tgz
Note: The software packages downloaded according to the preceding commands are stored in your current working directory. The wget command is a free tool for automatically downloading files from the network.
Note: The number in the command is the version number, which can be downloaded as needed.Step 2: Decompress the downloaded Binary Package and compile and install it.
[Plain] view plaincopy
- # TarzxvfPython-3.4.3.tgz
- # CdPython-3.4.3
- #./Configure
- # Makeall
- # Makeinstall
- # Makeclean
- # Makedistclean
- #/Usr/local/bin/python3-V
After compilation and installation, enter the preceding command to view the version.Step 2: Establish a soft connection to point to the bin directory of the default python command of the current system, so that the system can use the new version of python
[Plain] view plaincopy
- # Mv/usr/bin/python/usr/bin/python2.6 // The current python version is 2.6, so it is python2.6
- # Ln-s/usr/local/bin/python3.4/usr/bin/python
Enter # python-V to view the current default python version.
After the default python point to 3.4.3, yum cannot be used normally. You need to modify the yum configuration file.
Step 2: Modify the yum configuration file
[Plain] view plaincopy
- # Vim/usr/bin/yum
#! /Usr/bin/python #! /Usr/bin/python2.6 // change the old version
Save and exit. yum can be used normally. If other commands and software cannot be used normally, modify the configuration file just like the yum configuration file.