upgrade glibc According to INSTALL Upgrade instructions , requirement python edition 3.4 above . So you need to python Version upgrade .centos7 Default installed python Version is 2.7.5,python adopt yum Installation can only be installed 2.7.5 edition ,python3 Can pass yum install 3.6.8 edition . If you need a higher version , Can only be installed through source compilation . This blog post introduces how to upgrade the source code installation python and python3 edition , Source code compilation and installation requires that the operating system has been installed gcc. The environmental description is as follows :
[[email protected] ~]# python -V
Python 2.7.5
[[email protected] ~]# yum install -y python2
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package python-2.7.5-90.el7.x86_64 already installed and latest version
Nothing to do
[[email protected] ~]# yum install -y python3
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed:
python3.x86_64 0:3.6.8-18.el7
Dependency Installed:
libtirpc.x86_64 0:0.2.4-0.16.el7 python3-libs.x86_64 0:3.6.8-18.el7 python3-pip.noarch 0:9.0.3-8.el7 python3-setuptools.noarch 0:39.2.0-10.el7
Complete!
python Official website ( Include python and python3 All versions ) Find the version that needs to be installed or upgraded .
[[email protected] opt]# wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz
[[email protected] opt]# tar -zxvf Python-2.7.18.tgz
[[email protected] opt]# cd Python-2.7.18
[[email protected] Python-2.7.18]# ./configure --prefix=/usr
[[email protected] Python-2.7.18]# make
…
running build_scripts
creating build/scripts-2.7
copying and adjusting /opt/Python-2.7.18/Tools/scripts/pydoc -> build/scripts-2.7
copying and adjusting /opt/Python-2.7.18/Tools/scripts/idle -> build/scripts-2.7
copying and adjusting /opt/Python-2.7.18/Tools/scripts/2to3 -> build/scripts-2.7
copying and adjusting /opt/Python-2.7.18/Lib/smtpd.py -> build/scripts-2.7
changing mode of build/scripts-2.7/pydoc from 644 to 755
changing mode of build/scripts-2.7/idle from 644 to 755
changing mode of build/scripts-2.7/2to3 from 644 to 755
changing mode of build/scripts-2.7/smtpd.py from 644 to 755
/usr/bin/install -c -m 644 ./Tools/gdb/libpython.py python-gdb.py
[[email protected] Python-2.7.18]# make install
[[email protected] Python-2.7.18]# python -V
Python 2.7.18
[[email protected] opt]# wget https://www.python.org/ftp/python/3.8.8/Python-3.8.8.tgz
[[email protected] opt]# tar -zxvf Python-3.8.8.tgz
Note that there will be a prompt after the compilation "If you want a release build with all stable optimizations active (PGO, etc),please run ./configure --enable-optimizations", add –enable-optimizations If precompiled, subsequent compilation will report errors “Could not import runpy module ”, as a result of gcc Outdated Version ,enable-optimizations Parameter requirements gcc edition 8.1.0 above .
[[email protected] opt]# cd Python-3.8.8
[[email protected] Python-3.8.8]# ./configure
[[email protected] Python-3.8.8]# make
…
if test `uname -s` = Darwin; then
cp python-config.py python-config;
fi
[[email protected] Python-3.8.8]# make install
…
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-18.1 setuptools-40.6.2
[[email protected] Python-3.6.10]# python3 -V
Python 3.8.8