Upgrade reason: Since many features behind 2.7 are not supported, upgrading to 3.7 will avoid many problems
Viewing the Current Version
[root@localhost Python-3.7.4]# python -V
Python 2.7.5
Copy the code
- Install dependencies
yum install -y zlib-devel bzip2-devel openssl-devel libffi-devel ncurese-devel wget gcc gcc-c++ lrzsz
Copy the code
- Download the source code
# source address https://www.python.org/ftp/python CD/opt/python wget HTTP: / / https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xzCopy the code
- Compile the source code
[root@localhost python-3.7.4]# PWD /opt/ Python/python-3.7.4 [root@localhost python-3.7.4]# ls aclocal.m4 config.status Grammar LICENSE Makefile.pre.in PC pyconfig.h.in python-gdb.py build config.sub Include m4 Misc PCbuild python README.rst CODE_OF_CONDUCT.rst configure install-sh Mac Modules Programs Python setup.py config.guess configure.ac Lib TXT python-config Tools config.log Doc libpython3.7m.a makefile. pre Parser pyconfig.h Py [root@localhost python-3.7.4]#./configure --prefix=/usr/local/python3.7 [root@localhost python-3.7.4]# make && make installCopy the code
- Replace the version
[root@localhost python-3.7.4]# mv /usr/bin/python /usr/bin/python2.7.bk [root@localhost python-3.7.4]# ln -s / usr/local/python3.7 / bin/python3.7 / usr/bin/python/root @ localhost python - 3.7.4 # ln -s/usr/local/python3.7 / bin/pip3 /usr/bin/pip ln: Failed to create symbolic link '/usr/bin/pip' : File exists [root@localhost python-3.7.4]# mv /usr/bin/pi PIC pinentry ping pinky pip2 piconv pinentry-curses ping6 PIP Pip2.7 [root@localhost python-3.7.4]# mv /usr/bin/pi PIC pinentry ping pinky pip2 piconv pinentry-curses ping6 PIP Pip2.7 [root@localhost python-3.7.4]# mv /usr/bin/pip /usr/bin/pip2.7.bk [root@localhost python-3.7.4]# ln -s / usr/local/python3.7 / bin/pip3 / usr/bin/PIP/root @ localhost Python - 3.7.4 # Python -v Python 3.7.4 [root @ localhost Python - 3.7.4] # PIP - V PIP 19.0.3 from/usr/local/python3.7 / lib/python3.7 / site - packages/PIP (Python 3.7) [root @ localhost Python - 3.7.4] #Copy the code
- Update the yum!
Vi /usr/bin/yum #! The/usr/bin/python2.7 vi/usr/libexec/urlgrabber - ext - down #! The/usr/bin/python2.7Copy the code