CentOS安装Python3

一、查看CentOS版本

1、查看已安装的CentOS版本信息:

[root@HadoopLinux ~]# cat /proc/version
Linux version 3.10.0-862.14.4.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Wed Sep 26 15:12:11 UTC 2018
[root@HadoopLinux ~]# uname -a
Linux HadoopLinux 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@HadoopLinux ~]# uname -r
3.10.0-862.14.4.el7.x86_64
 

2、查看linux版本:

[root@HadoopLinux ~]# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID:    CentOS
Description:    CentOS Linux release 7.5.1804 (Core)
Release:    7.5.1804
Codename:    Core

[root@HadoopLinux ~]# cat /etc/issue
\S
Kernel \r on an \m

[root@HadoopLinux ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

 

3、查看系统是64位还是32位:

[root@HadoopLinux ~]# getconf LONG_BIT
64
[root@HadoopLinux ~]# file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=c5ad78cfc1de12b9bb6829207cececb990b3e987, stripped
[root@HadoopLinux ~]# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID:    CentOS
Description:    CentOS Linux release 7.5.1804 (Core)
Release:    7.5.1804

二、安装python3

1、查看python版本

[root@HadoopLinux ~]# python -v
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /usr/lib64/python2.7/site.pyc matches /usr/lib64/python2.7/site.py
import site # precompiled from /usr/lib64/python2.7/site.pyc
# /usr/lib64/python2.7/os.pyc matches /usr/lib64/python2.7/os.py
import os # precompiled from /usr/lib64/python2.7/os.pyc
import errno # builtin
import posix # builtin
# /usr/lib64/python2.7/posixpath.pyc matches /usr/lib64/python2.7/posixpath.py
import posixpath # precompiled from /usr/lib64/python2.7/posixpath.pyc
# /usr/lib64/python2.7/stat.pyc matches /usr/lib64/python2.7/stat.py
import stat # precompiled from /usr/lib64/python2.7/stat.pyc
# /usr/lib64/python2.7/genericpath.pyc matches /usr/lib64/python2.7/genericpath.py
import genericpath # precompiled from /usr/lib64/python2.7/genericpath.pyc
# /usr/lib64/python2.7/warnings.pyc matches /usr/lib64/python2.7/warnings.py
import warnings # precompiled from /usr/lib64/python2.7/warnings.pyc
# /usr/lib64/python2.7/linecache.pyc matches /usr/lib64/python2.7/linecache.py
import linecache # precompiled from /usr/lib64/python2.7/linecache.pyc
# /usr/lib64/python2.7/types.pyc matches /usr/lib64/python2.7/types.py
import types # precompiled from /usr/lib64/python2.7/types.pyc
# /usr/lib64/python2.7/UserDict.pyc matches /usr/lib64/python2.7/UserDict.py
import UserDict # precompiled from /usr/lib64/python2.7/UserDict.pyc
# /usr/lib64/python2.7/_abcoll.pyc matches /usr/lib64/python2.7/_abcoll.py
import _abcoll # precompiled from /usr/lib64/python2.7/_abcoll.pyc
# /usr/lib64/python2.7/abc.pyc matches /usr/lib64/python2.7/abc.py
import abc # precompiled from /usr/lib64/python2.7/abc.pyc
# /usr/lib64/python2.7/_weakrefset.pyc matches /usr/lib64/python2.7/_weakrefset.py
import _weakrefset # precompiled from /usr/lib64/python2.7/_weakrefset.pyc
import _weakref # builtin
# /usr/lib64/python2.7/copy_reg.pyc matches /usr/lib64/python2.7/copy_reg.py
import copy_reg # precompiled from /usr/lib64/python2.7/copy_reg.pyc
# /usr/lib64/python2.7/traceback.pyc matches /usr/lib64/python2.7/traceback.py
import traceback # precompiled from /usr/lib64/python2.7/traceback.pyc
# /usr/lib64/python2.7/sysconfig.pyc matches /usr/lib64/python2.7/sysconfig.py
import sysconfig # precompiled from /usr/lib64/python2.7/sysconfig.pyc
# /usr/lib64/python2.7/re.pyc matches /usr/lib64/python2.7/re.py
import re # precompiled from /usr/lib64/python2.7/re.pyc
# /usr/lib64/python2.7/sre_compile.pyc matches /usr/lib64/python2.7/sre_compile.py
import sre_compile # precompiled from /usr/lib64/python2.7/sre_compile.pyc
import _sre # builtin
# /usr/lib64/python2.7/sre_parse.pyc matches /usr/lib64/python2.7/sre_parse.py
import sre_parse # precompiled from /usr/lib64/python2.7/sre_parse.pyc
# /usr/lib64/python2.7/sre_constants.pyc matches /usr/lib64/python2.7/sre_constants.py
import sre_constants # precompiled from /usr/lib64/python2.7/sre_constants.pyc
# /usr/lib64/python2.7/_sysconfigdata.pyc matches /usr/lib64/python2.7/_sysconfigdata.py
import _sysconfigdata # precompiled from /usr/lib64/python2.7/_sysconfigdata.pyc
import encodings # directory /usr/lib64/python2.7/encodings
# /usr/lib64/python2.7/encodings/__init__.pyc matches /usr/lib64/python2.7/encodings/__init__.py
import encodings # precompiled from /usr/lib64/python2.7/encodings/__init__.pyc
# /usr/lib64/python2.7/codecs.pyc matches /usr/lib64/python2.7/codecs.py
import codecs # precompiled from /usr/lib64/python2.7/codecs.pyc
import _codecs # builtin
# /usr/lib64/python2.7/encodings/aliases.pyc matches /usr/lib64/python2.7/encodings/aliases.py
import encodings.aliases # precompiled from /usr/lib64/python2.7/encodings/aliases.pyc
# /usr/lib64/python2.7/encodings/utf_8.pyc matches /usr/lib64/python2.7/encodings/utf_8.py
import encodings.utf_8 # precompiled from /usr/lib64/python2.7/encodings/utf_8.pyc
Python 2.7.5 (default, Jul 13 2018, 13:06:57) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/usr/lib64/python2.7/lib-dynload/readline.so", 2);
import readline # dynamically loaded from /usr/lib64/python2.7/lib-dynload/readline.so

2、升级Python版本

第一步:安装相关依赖包和编译环境

如果不安装相关依赖包,在使用pip安装python包时会出现找不到SSL错误!

[root@HadoopLinux ~]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel gcc
Loaded plugins: fastestmirror
Determining fastest mirrors
base                                                                                                                                                                                                                                                     | 3.6 kB  00:00:00     
epel                                                                                                                                                                                                                                                     | 4.7 kB  00:00:00     
extras                                                                                                                                                                                                                                                   | 2.9 kB  00:00:00     
updates                                                                                                                                                                                                                                                  | 2.9 kB  00:00:00     
(1/7): epel/x86_64/group_gz                                                                                                                                                                                                                              |  96 kB  00:00:00     
(2/7): epel/x86_64/updateinfo                                                                                                                                                                                                                            | 1.0 MB  00:00:00     
(3/7): base/7/x86_64/group_gz                                                                                                                                                                                                                            | 153 kB  00:00:00     
(4/7): base/7/x86_64/primary_db                                                                                                                                                                                                                          | 6.1 MB  00:00:00     
(5/7): updates/7/x86_64/primary_db                                                                                                                                                                                                                       |  15 MB  00:00:00     
(6/7): extras/7/x86_64/primary_db                                                                                                                                                                                                                        | 246 kB  00:00:00     
(7/7): epel/x86_64/primary_db                                                                                                                                                                                                                            | 7.0 MB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package bzip2-devel.x86_64 0:1.0.6-13.el7 will be installed
---> Package gcc.x86_64 0:4.8.5-28.el7_5.1 will be updated
---> Package gcc.x86_64 0:4.8.5-44.el7 will be an update
--> Processing Dependency: libgomp = 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: cpp = 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: libgcc >= 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64
---> Package gdbm-devel.x86_64 0:1.10-8.el7 will be installed
---> Package libdb4-devel.x86_64 0:4.8.30-13.el7 will be installed
--> Processing Dependency: libdb4(x86-64) = 4.8.30-13.el7 for package: libdb4-devel-4.8.30-13.el7.x86_64
---> Package libpcap-devel.x86_64 14:1.5.3-13.el7_9 will be installed
--> Processing Dependency: libpcap = 14:1.5.3-13.el7_9 for package: 14:libpcap-devel-1.5.3-13.el7_9.x86_64
---> Package ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 will be installed
---> Package openssl-devel.x86_64 1:1.0.2k-25.el7_9 will be installed
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-25.el7_9 for package: 1:openssl-devel-1.0.2k-25.el7_9.x86_64
--> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-25.el7_9.x86_64
---> Package readline-devel.x86_64 0:6.2-11.el7 will be installed
--> Processing Dependency: readline = 6.2-11.el7 for package: readline-devel-6.2-11.el7.x86_64
---> Package sqlite-devel.x86_64 0:3.7.17-8.el7_7.1 will be installed
--> Processing Dependency: sqlite = 3.7.17-8.el7_7.1 for package: sqlite-devel-3.7.17-8.el7_7.1.x86_64
---> Package tk-devel.x86_64 1:8.5.13-6.el7 will be installed
--> Processing Dependency: tk = 1:8.5.13-6.el7 for package: 1:tk-devel-8.5.13-6.el7.x86_64
--> Processing Dependency: tcl-devel = 1:8.5.13 for package: 1:tk-devel-8.5.13-6.el7.x86_64
--> Processing Dependency: libXft-devel for package: 1:tk-devel-8.5.13-6.el7.x86_64
--> Processing Dependency: libX11-devel for package: 1:tk-devel-8.5.13-6.el7.x86_64
---> Package xz-devel.x86_64 0:5.2.2-1.el7 will be installed
---> Package zlib-devel.x86_64 0:1.2.7-19.el7_9 will be installed
--> Processing Dependency: zlib = 1.2.7-19.el7_9 for package: zlib-devel-1.2.7-19.el7_9.x86_64
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-28.el7_5.1 will be updated
---> Package cpp.x86_64 0:4.8.5-44.el7 will be an update
---> Package krb5-devel.x86_64 0:1.15.1-51.el7_9 will be installed
--> Processing Dependency: libkadm5(x86-64) = 1.15.1-51.el7_9 for package: krb5-devel-1.15.1-51.el7_9.x86_64
--> Processing Dependency: krb5-libs(x86-64) = 1.15.1-51.el7_9 for package: krb5-devel-1.15.1-51.el7_9.x86_64
--> Processing Dependency: libverto-devel for package: krb5-devel-1.15.1-51.el7_9.x86_64
--> Processing Dependency: libselinux-devel for package: krb5-devel-1.15.1-51.el7_9.x86_64
--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.15.1-51.el7_9.x86_64
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.15.1-51.el7_9.x86_64
---> Package libX11-devel.x86_64 0:1.6.7-4.el7_9 will be installed
--> Processing Dependency: libX11 = 1.6.7-4.el7_9 for package: libX11-devel-1.6.7-4.el7_9.x86_64
--> Processing Dependency: pkgconfig(xcb) >= 1.11.1 for package: libX11-devel-1.6.7-4.el7_9.x86_64
--> Processing Dependency: pkgconfig(xproto) for package: libX11-devel-1.6.7-4.el7_9.x86_64
--> Processing Dependency: pkgconfig(xcb) for package: libX11-devel-1.6.7-4.el7_9.x86_64
--> Processing Dependency: pkgconfig(kbproto) for package: libX11-devel-1.6.7-4.el7_9.x86_64
--> Processing Dependency: libX11.so.6()(64bit) for package: libX11-devel-1.6.7-4.el7_9.x86_64
--> Processing Dependency: libX11-xcb.so.1()(64bit) for package: libX11-devel-1.6.7-4.el7_9.x86_64
---> Package libXft-devel.x86_64 0:2.3.2-2.el7 will be installed
--> Processing Dependency: libXft = 2.3.2-2.el7 for package: libXft-devel-2.3.2-2.el7.x86_64
--> Processing Dependency: pkgconfig(xrender) for package: libXft-devel-2.3.2-2.el7.x86_64
--> Processing Dependency: pkgconfig(freetype2) for package: libXft-devel-2.3.2-2.el7.x86_64
--> Processing Dependency: pkgconfig(fontconfig) for package: libXft-devel-2.3.2-2.el7.x86_64
--> Processing Dependency: libXft.so.2()(64bit) for package: libXft-devel-2.3.2-2.el7.x86_64
---> Package libdb4.x86_64 0:4.8.30-13.el7 will be installed
---> Package libgcc.x86_64 0:4.8.5-28.el7_5.1 will be updated
---> Package libgcc.x86_64 0:4.8.5-44.el7 will be an update
---> Package libgomp.x86_64 0:4.8.5-28.el7_5.1 will be updated
---> Package libgomp.x86_64 0:4.8.5-44.el7 will be an update
---> Package libpcap.x86_64 14:1.5.3-11.el7 will be updated
---> Package libpcap.x86_64 14:1.5.3-13.el7_9 will be an update
---> Package openssl-libs.x86_64 1:1.0.2k-12.el7 will be updated
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-12.el7 for package: 1:openssl-1.0.2k-12.el7.x86_64
---> Package openssl-libs.x86_64 1:1.0.2k-25.el7_9 will be an update
---> Package readline.x86_64 0:6.2-10.el7 will be updated
---> Package readline.x86_64 0:6.2-11.el7 will be an update
---> Package sqlite.x86_64 0:3.7.17-8.el7 will be updated
---> Package sqlite.x86_64 0:3.7.17-8.el7_7.1 will be an update
---> Package tcl-devel.x86_64 1:8.5.13-8.el7 will be installed
--> Processing Dependency: tcl = 1:8.5.13-8.el7 for package: 1:tcl-devel-8.5.13-8.el7.x86_64
---> Package tk.x86_64 1:8.5.13-6.el7 will be installed
---> Package zlib.x86_64 0:1.2.7-17.el7 will be updated
---> Package zlib.x86_64 0:1.2.7-19.el7_9 will be an update
--> Running transaction check
---> Package fontconfig-devel.x86_64 0:2.13.0-4.3.el7 will be installed
--> Processing Dependency: fontconfig(x86-64) = 2.13.0-4.3.el7 for package: fontconfig-devel-2.13.0-4.3.el7.x86_64
--> Processing Dependency: pkgconfig(uuid) for package: fontconfig-devel-2.13.0-4.3.el7.x86_64
--> Processing Dependency: pkgconfig(expat) for package: fontconfig-devel-2.13.0-4.3.el7.x86_64
--> Processing Dependency: libfontconfig.so.1()(64bit) for package: fontconfig-devel-2.13.0-4.3.el7.x86_64
---> Package freetype-devel.x86_64 0:2.8-14.el7_9.1 will be installed
--> Processing Dependency: freetype = 2.8-14.el7_9.1 for package: freetype-devel-2.8-14.el7_9.1.x86_64
--> Processing Dependency: pkgconfig(libpng) for package: freetype-devel-2.8-14.el7_9.1.x86_64
---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed
---> Package krb5-libs.x86_64 0:1.15.1-19.el7 will be updated
---> Package krb5-libs.x86_64 0:1.15.1-51.el7_9 will be an update
---> Package libX11.x86_64 0:1.6.7-4.el7_9 will be installed
--> Processing Dependency: libX11-common >= 1.6.7-4.el7_9 for package: libX11-1.6.7-4.el7_9.x86_64
--> Processing Dependency: libxcb.so.1()(64bit) for package: libX11-1.6.7-4.el7_9.x86_64
---> Package libXft.x86_64 0:2.3.2-2.el7 will be installed
--> Processing Dependency: libXrender.so.1()(64bit) for package: libXft-2.3.2-2.el7.x86_64
---> Package libXrender-devel.x86_64 0:0.9.10-1.el7 will be installed
---> Package libcom_err-devel.x86_64 0:1.42.9-19.el7 will be installed
--> Processing Dependency: libcom_err(x86-64) = 1.42.9-19.el7 for package: libcom_err-devel-1.42.9-19.el7.x86_64
---> Package libkadm5.x86_64 0:1.15.1-51.el7_9 will be installed
---> Package libselinux-devel.x86_64 0:2.5-15.el7 will be installed
--> Processing Dependency: libselinux(x86-64) = 2.5-15.el7 for package: libselinux-devel-2.5-15.el7.x86_64
--> Processing Dependency: libsepol-devel(x86-64) >= 2.5-10 for package: libselinux-devel-2.5-15.el7.x86_64
--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.5-15.el7.x86_64
--> Processing Dependency: pkgconfig(libpcre) for package: libselinux-devel-2.5-15.el7.x86_64
---> Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed
---> Package libxcb-devel.x86_64 0:1.13-1.el7 will be installed
--> Processing Dependency: pkgconfig(xau) >= 0.99.2 for package: libxcb-devel-1.13-1.el7.x86_64
---> Package openssl.x86_64 1:1.0.2k-12.el7 will be updated
---> Package openssl.x86_64 1:1.0.2k-25.el7_9 will be an update
---> Package tcl.x86_64 1:8.5.13-8.el7 will be installed
---> Package xorg-x11-proto-devel.noarch 0:2018.4-1.el7 will be installed
--> Running transaction check
---> Package expat-devel.x86_64 0:2.1.0-14.el7_9 will be installed
--> Processing Dependency: expat = 2.1.0-14.el7_9 for package: expat-devel-2.1.0-14.el7_9.x86_64
---> Package fontconfig.x86_64 0:2.13.0-4.3.el7 will be installed
--> Processing Dependency: fontpackages-filesystem for package: fontconfig-2.13.0-4.3.el7.x86_64
--> Processing Dependency: dejavu-sans-fonts for package: fontconfig-2.13.0-4.3.el7.x86_64
---> Package freetype.x86_64 0:2.4.11-15.el7 will be updated
---> Package freetype.x86_64 0:2.8-14.el7_9.1 will be an update
--> Processing Dependency: libpng15.so.15(PNG15_0)(64bit) for package: freetype-2.8-14.el7_9.1.x86_64
--> Processing Dependency: libpng15.so.15()(64bit) for package: freetype-2.8-14.el7_9.1.x86_64
---> Package libX11-common.noarch 0:1.6.7-4.el7_9 will be installed
---> Package libXau-devel.x86_64 0:1.0.8-2.1.el7 will be installed
--> Processing Dependency: libXau = 1.0.8-2.1.el7 for package: libXau-devel-1.0.8-2.1.el7.x86_64
--> Processing Dependency: libXau.so.6()(64bit) for package: libXau-devel-1.0.8-2.1.el7.x86_64
---> Package libXrender.x86_64 0:0.9.10-1.el7 will be installed
---> Package libcom_err.x86_64 0:1.42.9-12.el7_5 will be updated
--> Processing Dependency: libcom_err(x86-64) = 1.42.9-12.el7_5 for package: libss-1.42.9-12.el7_5.x86_64
--> Processing Dependency: libcom_err(x86-64) = 1.42.9-12.el7_5 for package: e2fsprogs-libs-1.42.9-12.el7_5.x86_64
--> Processing Dependency: libcom_err(x86-64) = 1.42.9-12.el7_5 for package: e2fsprogs-1.42.9-12.el7_5.x86_64
---> Package libcom_err.x86_64 0:1.42.9-19.el7 will be an update
---> Package libpng-devel.x86_64 2:1.5.13-8.el7 will be installed
---> Package libselinux.x86_64 0:2.5-12.el7 will be updated
--> Processing Dependency: libselinux(x86-64) = 2.5-12.el7 for package: libselinux-python-2.5-12.el7.x86_64
--> Processing Dependency: libselinux(x86-64) = 2.5-12.el7 for package: libselinux-utils-2.5-12.el7.x86_64
---> Package libselinux.x86_64 0:2.5-15.el7 will be an update
--> Processing Dependency: libsepol(x86-64) >= 2.5-10 for package: libselinux-2.5-15.el7.x86_64
---> Package libsepol-devel.x86_64 0:2.5-10.el7 will be installed
---> Package libuuid-devel.x86_64 0:2.23.2-65.el7_9.1 will be installed
--> Processing Dependency: libuuid = 2.23.2-65.el7_9.1 for package: libuuid-devel-2.23.2-65.el7_9.1.x86_64
---> Package libxcb.x86_64 0:1.13-1.el7 will be installed
---> Package pcre-devel.x86_64 0:8.32-17.el7 will be installed
--> Running transaction check
---> Package dejavu-sans-fonts.noarch 0:2.33-6.el7 will be installed
--> Processing Dependency: dejavu-fonts-common = 2.33-6.el7 for package: dejavu-sans-fonts-2.33-6.el7.noarch
---> Package e2fsprogs.x86_64 0:1.42.9-12.el7_5 will be updated
---> Package e2fsprogs.x86_64 0:1.42.9-19.el7 will be an update
---> Package e2fsprogs-libs.x86_64 0:1.42.9-12.el7_5 will be updated
---> Package e2fsprogs-libs.x86_64 0:1.42.9-19.el7 will be an update
---> Package expat.x86_64 0:2.1.0-10.el7_3 will be updated
---> Package expat.x86_64 0:2.1.0-14.el7_9 will be an update
---> Package fontpackages-filesystem.noarch 0:1.44-8.el7 will be installed
---> Package libXau.x86_64 0:1.0.8-2.1.el7 will be installed
---> Package libpng.x86_64 2:1.5.13-8.el7 will be installed
---> Package libselinux-python.x86_64 0:2.5-12.el7 will be updated
---> Package libselinux-python.x86_64 0:2.5-15.el7 will be an update
---> Package libselinux-utils.x86_64 0:2.5-12.el7 will be updated
---> Package libselinux-utils.x86_64 0:2.5-15.el7 will be an update
---> Package libsepol.x86_64 0:2.5-8.1.el7 will be updated
---> Package libsepol.x86_64 0:2.5-10.el7 will be an update
---> Package libss.x86_64 0:1.42.9-12.el7_5 will be updated
---> Package libss.x86_64 0:1.42.9-19.el7 will be an update
---> Package libuuid.x86_64 0:2.23.2-52.el7_5.1 will be updated
--> Processing Dependency: libuuid = 2.23.2-52.el7_5.1 for package: libblkid-2.23.2-52.el7_5.1.x86_64
--> Processing Dependency: libuuid = 2.23.2-52.el7_5.1 for package: libmount-2.23.2-52.el7_5.1.x86_64
--> Processing Dependency: libuuid = 2.23.2-52.el7_5.1 for package: util-linux-2.23.2-52.el7_5.1.x86_64
---> Package libuuid.x86_64 0:2.23.2-65.el7_9.1 will be an update
--> Running transaction check
---> Package dejavu-fonts-common.noarch 0:2.33-6.el7 will be installed
---> Package libblkid.x86_64 0:2.23.2-52.el7_5.1 will be updated
---> Package libblkid.x86_64 0:2.23.2-65.el7_9.1 will be an update
---> Package libmount.x86_64 0:2.23.2-52.el7_5.1 will be updated
---> Package libmount.x86_64 0:2.23.2-65.el7_9.1 will be an update
---> Package util-linux.x86_64 0:2.23.2-52.el7_5.1 will be updated
---> Package util-linux.x86_64 0:2.23.2-65.el7_9.1 will be an update
--> Processing Dependency: libsmartcols = 2.23.2-65.el7_9.1 for package: util-linux-2.23.2-65.el7_9.1.x86_64
--> Processing Dependency: libsmartcols.so.1(SMARTCOLS_2.25)(64bit) for package: util-linux-2.23.2-65.el7_9.1.x86_64
--> Processing Dependency: libsmartcols.so.1()(64bit) for package: util-linux-2.23.2-65.el7_9.1.x86_64
--> Running transaction check
---> Package libsmartcols.x86_64 0:2.23.2-65.el7_9.1 will be installed
--> Finished Dependency Resolution

......

Installed:
  bzip2-devel.x86_64 0:1.0.6-13.el7       gdbm-devel.x86_64 0:1.10-8.el7  libdb4-devel.x86_64 0:4.8.30-13.el7  libpcap-devel.x86_64 14:1.5.3-13.el7_9  ncurses-devel.x86_64 0:5.9-14.20130511.el7_4  openssl-devel.x86_64 1:1.0.2k-25.el7_9  readline-devel.x86_64 0:6.2-11.el7 
  sqlite-devel.x86_64 0:3.7.17-8.el7_7.1  tk-devel.x86_64 1:8.5.13-6.el7  xz-devel.x86_64 0:5.2.2-1.el7        zlib-devel.x86_64 0:1.2.7-19.el7_9     

Dependency Installed:
  dejavu-fonts-common.noarch 0:2.33-6.el7     dejavu-sans-fonts.noarch 0:2.33-6.el7        expat-devel.x86_64 0:2.1.0-14.el7_9          fontconfig.x86_64 0:2.13.0-4.3.el7      fontconfig-devel.x86_64 0:2.13.0-4.3.el7       fontpackages-filesystem.noarch 0:1.44-8.el7    
  freetype-devel.x86_64 0:2.8-14.el7_9.1      keyutils-libs-devel.x86_64 0:1.5.8-3.el7     krb5-devel.x86_64 0:1.15.1-51.el7_9          libX11.x86_64 0:1.6.7-4.el7_9           libX11-common.noarch 0:1.6.7-4.el7_9           libX11-devel.x86_64 0:1.6.7-4.el7_9            
  libXau.x86_64 0:1.0.8-2.1.el7               libXau-devel.x86_64 0:1.0.8-2.1.el7          libXft.x86_64 0:2.3.2-2.el7                  libXft-devel.x86_64 0:2.3.2-2.el7       libXrender.x86_64 0:0.9.10-1.el7               libXrender-devel.x86_64 0:0.9.10-1.el7         
  libcom_err-devel.x86_64 0:1.42.9-19.el7     libdb4.x86_64 0:4.8.30-13.el7                libkadm5.x86_64 0:1.15.1-51.el7_9            libpng.x86_64 2:1.5.13-8.el7            libpng-devel.x86_64 2:1.5.13-8.el7             libselinux-devel.x86_64 0:2.5-15.el7           
  libsepol-devel.x86_64 0:2.5-10.el7          libsmartcols.x86_64 0:2.23.2-65.el7_9.1      libuuid-devel.x86_64 0:2.23.2-65.el7_9.1     libverto-devel.x86_64 0:0.2.5-4.el7     libxcb.x86_64 0:1.13-1.el7                     libxcb-devel.x86_64 0:1.13-1.el7               
  pcre-devel.x86_64 0:8.32-17.el7             tcl.x86_64 1:8.5.13-8.el7                    tcl-devel.x86_64 1:8.5.13-8.el7              tk.x86_64 1:8.5.13-6.el7                xorg-x11-proto-devel.noarch 0:2018.4-1.el7    

Updated:
  gcc.x86_64 0:4.8.5-44.el7                                                                                                                                                                                                                                                     

Dependency Updated:
  cpp.x86_64 0:4.8.5-44.el7             e2fsprogs.x86_64 0:1.42.9-19.el7       e2fsprogs-libs.x86_64 0:1.42.9-19.el7  expat.x86_64 0:2.1.0-14.el7_9        freetype.x86_64 0:2.8-14.el7_9.1  krb5-libs.x86_64 0:1.15.1-51.el7_9     libblkid.x86_64 0:2.23.2-65.el7_9.1   
  libcom_err.x86_64 0:1.42.9-19.el7     libgcc.x86_64 0:4.8.5-44.el7           libgomp.x86_64 0:4.8.5-44.el7          libmount.x86_64 0:2.23.2-65.el7_9.1  libpcap.x86_64 14:1.5.3-13.el7_9  libselinux.x86_64 0:2.5-15.el7         libselinux-python.x86_64 0:2.5-15.el7 
  libselinux-utils.x86_64 0:2.5-15.el7  libsepol.x86_64 0:2.5-10.el7           libss.x86_64 0:1.42.9-19.el7           libuuid.x86_64 0:2.23.2-65.el7_9.1   openssl.x86_64 1:1.0.2k-25.el7_9  openssl-libs.x86_64 1:1.0.2k-25.el7_9  readline.x86_64 0:6.2-11.el7          
  sqlite.x86_64 0:3.7.17-8.el7_7.1      util-linux.x86_64 0:2.23.2-65.el7_9.1  zlib.x86_64 0:1.2.7-19.el7_9          

Complete!
[root@HadoopLinux ~]# 

第二步:下载python3.8.0安装包

[root@HadoopLinux ~]# wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xz
--2022-05-06 15:27:28--  https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xz
Resolving www.python.org (www.python.org)... 151.101.72.223
Connecting to www.python.org (www.python.org)|151.101.72.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 17829824 (17M) [application/octet-stream]
Saving to: ‘Python-3.8.0.tar.xz’

100%[==============================================================================================================================================================================================>] 17,829,824  22.6KB/s   in 11m 18s

2022-05-06 15:38:49 (25.7 KB/s) - ‘Python-3.8.0.tar.xz’ saved [17829824/17829824]

第三步:解压安装包并创建安装目录

[root@HadoopLinux ~]# xz -d Python-3.8.0.tar.xz
[root@HadoopLinux ~]# tar -xvf Python-3.8.0.tar
Python-3.8.0/
Python-3.8.0/CODE_OF_CONDUCT.md
Python-3.8.0/README.rst
Python-3.8.0/Doc/
Python-3.8.0/Doc/howto/
Python-3.8.0/Doc/howto/pyporting.rst
Python-3.8.0/Doc/howto/logging-cookbook.rst
Python-3.8.0/Doc/howto/logging_flow.png
Python-3.8.0/Doc/howto/sorting.rst
Python-3.8.0/Doc/howto/functional.rst
Python-3.8.0/Doc/howto/regex.rst
Python-3.8.0/Doc/howto/ipaddress.rst
Python-3.8.0/Doc/howto/argparse.rst
Python-3.8.0/Doc/howto/urllib2.rst
Python-3.8.0/Doc/howto/unicode.rst
Python-3.8.0/Doc/howto/index.rst
Python-3.8.0/Doc/howto/logging.rst
Python-3.8.0/Doc/howto/curses.rst
Python-3.8.0/Doc/howto/descriptor.rst
Python-3.8.0/Doc/howto/sockets.rst
Python-3.8.0/Doc/howto/instrumentation.rst
Python-3.8.0/Doc/howto/cporting.rst
Python-3.8.0/Doc/howto/clinic.rst
Python-3.8.0/Doc/README.rst
Python-3.8.0/Doc/install/
Python-3.8.0/Doc/install/index.rst
Python-3.8.0/Doc/whatsnew/
Python-3.8.0/Doc/whatsnew/3.6.rst
Python-3.8.0/Doc/whatsnew/2.2.rst
Python-3.8.0/Doc/whatsnew/3.8.rst
Python-3.8.0/Doc/whatsnew/changelog.rst
Python-3.8.0/Doc/whatsnew/3.2.rst
Python-3.8.0/Doc/whatsnew/3.5.rst
Python-3.8.0/Doc/whatsnew/2.6.rst
Python-3.8.0/Doc/whatsnew/3.0.rst
Python-3.8.0/Doc/whatsnew/2.7.rst
Python-3.8.0/Doc/whatsnew/3.3.rst
Python-3.8.0/Doc/whatsnew/index.rst
Python-3.8.0/Doc/whatsnew/2.0.rst
Python-3.8.0/Doc/whatsnew/2.4.rst
Python-3.8.0/Doc/whatsnew/2.1.rst
Python-3.8.0/Doc/whatsnew/2.5.rst
Python-3.8.0/Doc/whatsnew/2.3.rst
Python-3.8.0/Doc/whatsnew/3.7.rst
Python-3.8.0/Doc/whatsnew/3.1.rst
Python-3.8.0/Doc/whatsnew/3.4.rst
Python-3.8.0/Doc/license.rst
Python-3.8.0/Doc/tutorial/
Python-3.8.0/Doc/tutorial/controlflow.rst
Python-3.8.0/Doc/tutorial/interactive.rst
Python-3.8.0/Doc/tutorial/whatnow.rst
Python-3.8.0/Doc/tutorial/appetite.rst
Python-3.8.0/Doc/tutorial/interpreter.rst
Python-3.8.0/Doc/tutorial/errors.rst
Python-3.8.0/Doc/tutorial/inputoutput.rst
Python-3.8.0/Doc/tutorial/datastructures.rst
Python-3.8.0/Doc/tutorial/stdlib2.rst
Python-3.8.0/Doc/tutorial/floatingpoint.rst
Python-3.8.0/Doc/tutorial/appendix.rst
Python-3.8.0/Doc/tutorial/stdlib.rst
Python-3.8.0/Doc/tutorial/venv.rst
Python-3.8.0/Doc/tutorial/index.rst
Python-3.8.0/Doc/tutorial/introduction.rst
Python-3.8.0/Doc/tutorial/classes.rst
Python-3.8.0/Doc/tutorial/modules.rst
Python-3.8.0/Doc/tools/
Python-3.8.0/Doc/tools/static/
Python-3.8.0/Doc/tools/static/changelog_search.js
Python-3.8.0/Doc/tools/static/switchers.js
Python-3.8.0/Doc/tools/susp-ignored.csv
Python-3.8.0/Doc/tools/templates/
Python-3.8.0/Doc/tools/templates/indexsidebar.html
Python-3.8.0/Doc/tools/templates/indexcontent.html
Python-3.8.0/Doc/tools/templates/layout.html
Python-3.8.0/Doc/tools/templates/customsourcelink.html
Python-3.8.0/Doc/tools/templates/opensearch.xml
Python-3.8.0/Doc/tools/templates/download.html
Python-3.8.0/Doc/tools/templates/dummy.html
Python-3.8.0/Doc/tools/extensions/
Python-3.8.0/Doc/tools/extensions/suspicious.py
Python-3.8.0/Doc/tools/extensions/patchlevel.py
Python-3.8.0/Doc/tools/extensions/pyspecific.py
Python-3.8.0/Doc/tools/extensions/escape4chm.py
Python-3.8.0/Doc/tools/extensions/c_annotations.py
Python-3.8.0/Doc/tools/rstlint.py
......
[root@HadoopLinux ~]# 

第四步:编译安装
 


[root@HadoopLinux ~]# mkdir /usr/local/python3.8.0
[root@HadoopLinux ~]# cd Python-3.8.0
[root@HadoopLinux Python-3.8.0]# ./configure --with-ssl --prefix=/usr/local/python3.8.0
configure: WARNING: unrecognized options: --with-ssl
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.8... no
checking for python3... no
checking for python... python
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "linux"
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for a sed that does not truncate output... /usr/bin/sed
checking for --with-cxx-main=<compiler>... no
checking for g++... no
configure:

  By default, distutils will build C++ extension modules with "g++".
  If this is not intended, then set CXX on the configure command line.
  
checking for the platform triplet based on compiler characteristics... x86_64-linux-gnu
checking for -Wl,--no-as-needed... yes
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
......
configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Misc/python.pc
config.status: creating Misc/python-embed.pc
config.status: creating Misc/python-config.sh
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
configure: WARNING: unrecognized options: --with-ssl
creating Modules/Setup.local
creating Makefile


If you want a release build with all stable optimizations active (PGO, etc),
please run ./configure --enable-optimizations

[root@HadoopLinux ~]# make && make install
make: *** No targets specified and no makefile found.  Stop.
[root@HadoopLinux ~]# cd Python-3.8.0
[root@HadoopLinux Python-3.8.0]# make && make install
gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration  -I./Include/internal  -I. -I./Include    -DPy_BUILD_CORE -o Programs/python.o ./Programs/python.c
gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration  -I./Include/internal  -I. -I./Include    -DPy_BUILD_CORE -o Parser/acceler.o Parser/acceler.c
......
Looking in links: /tmp/tmpyk3ll80a
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-19.2.3 setuptools-41.2.0

第五步:创建python3.8.0软链接

[root@HadoopLinux ~]# ln -s /usr/local/python3.8.0/bin/python3.8 /usr/bin/python3
[root@HadoopLinux ~]# ln -s /usr/local/python3.8.0/bin/pip3.8 /usr/bin/pip3
[root@HadoopLinux ~]# pip3 install --upgrade pip
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting pip
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/4d/16/0a14ca596f30316efd412a60bdfac02a7259bf8673d4d917dc60b9a21812/pip-22.0.4-py3-none-any.whl (2.1MB)
     |████████████████████████████████| 2.1MB 3.3MB/s 
Installing collected packages: pip
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
Successfully installed pip-22.0.4

第六步:修改python2.7.5软链接(这一步可有可无)

[root@HadoopLinux ~]# mv /usr/bin/python /usr/bin/python2
mv: overwrite ‘/usr/bin/python2’? y
[root@HadoopLinux ~]# 

第七步:验证,使用python3进入python3.8.0命令行

[root@HadoopLinux ~]# python3
Python 3.8.0 (default, May  6 2022, 15:51:36) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值