Create a directory python3.6.5 installation directory:
mkdir /usr/local/python3.6.5
Into the installation directory:
cd /usr/local/python3.6.5
Execute the following command to download the python package install
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
Extracting installation package
tar -xzvf Python-3.6.5.tgz
The following commands to switch to extract the directory:
CD-3.6.5 the Python
Run the following commands, installed gcc assembly
yum install make gcc gcc-c ++
Run the following commands, provided installation of python
./configure -prefix = / usr / local / python3.6.5
Execute the following command to install Python
the make the make install &&
If the following error occurs, the reason for the lack zlib package, execute the command yum install zlib * zlib installed after
re-run make && make install install python:
zipimport.ZipImportError: can not decompress data; zlib not available
to perform the command echo $ verify that the installation is successful, the output is 0 installation is successful?
If you want to retain the original version of python, two steps may not be performed (preferably retain the original version, or else a lot of linux command abnormalities),
just execute the command ln -s /usr/local/python3.6.5/bin/python3.6 / usr / bin / python3 can be.
Modify environment variables python link:
Execute the following command to back up the original Python
cp / usr / bin / Python /usr/bin/python.bak
Execute the following command to delete the original Python
RM -f / usr / bin / Python
Execute the following command to link the new python environment variable
ln -s /usr/local/python3.6.5/bin/python3.6 / usr / bin / python
Verify successful upgrade
python -V