CentOS 8.0 升级Python版本到3.8.0

CentOS 8.0系统的安装见文章《CentOS 8.0 图形化安装》
CentOS 8.0系统的基本配置见文章《CentOS 8.0 基本配置》
CentOS 8.0系统创建LVM分区见文章《CentOS 8.0 创建LVM分区》

1. 下载并安装Python 3.8.0
[root@Server ~]# python3 -V
Python 3.6.8
[root@Server ~]# cd /Data/Downloads/
[root@Server Downloads]# wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz           //下载Python 3.8.0安装包
--2019-10-16 11:59:55--  https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
Resolving www.python.org (www.python.org)... 151.101.228.223, 2a04:4e42:1a::223
Connecting to www.python.org (www.python.org)|151.101.228.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 23949883 (23M) [application/octet-stream]
Saving to: ‘Python-3.8.0.tgz’

Python-3.8.0.tgz                                        100%[============================================================================================================================>]  22.84M   218KB/s    in 1m 44s

2019-10-16 12:01:40 (225 KB/s) - ‘Python-3.8.0.tgz’ saved [23949883/23949883]
[root@Server Downloads]# yum -y install gcc zlib* libffi-devel            //YUM安装编译Python所需要的开发包
Last metadata expiration check: 1:07:16 ago on Wed 16 Oct 2019 10:55:26 AM CST.
Package gcc-8.2.1-3.5.el8.x86_64 is already installed.
Package zlib-1.2.11-10.el8.x86_64 is already installed.
Package zlib-devel-1.2.11-10.el8.x86_64 is already installed.
Dependencies resolved.
(中间省略……)
  Running scriptlet: libffi-devel-3.1-18.el8.x86_64                                                                                 1/1
  Verifying        : libffi-devel-3.1-18.el8.x86_64                                                                                      1/1

Installed:
  libffi-devel-3.1-18.el8.x86_64

Complete!
[root@Server Downloads]# tar -zxvf Python-3.8.0.tgz                 //解压Python-3.7.4.tgz文件
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/Objects/listsort.txt
Python-3.8.0/Objects/enumobject.c
Python-3.8.0/Objects/sliceobject.c
Python-3.8.0/Objects/listobject.c
Python-3.8.0/Objects/typeslots.inc
Python-3.8.0/Objects/weakrefobject.c
Python-3.8.0/Objects/unicodeobject.c
Python-3.8.0/Objects/complexobject.c
Python-3.8.0/Objects/picklebufobject.c
Python-3.8.0/Objects/odictobject.c
Python-3.8.0/Objects/genobject.c
[root@Server Downloads]# cd Python-3.8.0/
[root@Server Python-3.8.0]# ./configure --prefix=/usr/local/bin/python3
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... python3
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=... 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 X509_VERIFY_PARAM_set1_host in libssl... yes
checking for --with-ssl-default-suites... python
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
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@Server Python-3.7.4]# make
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
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/grammar1.o Parser/grammar1.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/listnode.o Parser/listnode.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/node.o Parser/node.c
(中间省略……)
The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  atexit                pwd
time

running build_scripts
creating build/scripts-3.8
copying and adjusting /Data/Downloads/Python-3.8.0/Tools/scripts/pydoc3 -> build/scripts-3.8
copying and adjusting /Data/Downloads/Python-3.8.0/Tools/scripts/idle3 -> build/scripts-3.8
copying and adjusting /Data/Downloads/Python-3.8.0/Tools/scripts/2to3 -> build/scripts-3.8
changing mode of build/scripts-3.8/pydoc3 from 644 to 755
changing mode of build/scripts-3.8/idle3 from 644 to 755
changing mode of build/scripts-3.8/2to3 from 644 to 755
renaming build/scripts-3.8/pydoc3 to build/scripts-3.8/pydoc3.8
renaming build/scripts-3.8/idle3 to build/scripts-3.8/idle3.8
renaming build/scripts-3.8/2to3 to build/scripts-3.8/2to3-3.8
/usr/bin/install -c -m 644 ./Tools/gdb/libpython.py python-gdb.py
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/_testembed.o ./Programs/_testembed.c
gcc -pthread     -Xlinker -export-dynamic -o Programs/_testembed Programs/_testembed.o libpython3.8.a -lcrypt -lpthread -ldl  -lutil -lm   -lm
sed -e "s,@EXENAME@,/usr/local/bin/python3/bin/python3.8," < ./Misc/python-config.in >python-config.py
LC_ALL=C sed -e 's,\$(\([A-Za-z0-9_]*\)),\$\{\1\},g' < Misc/python-config.sh >python-config
[root@Server Python-3.7.4]# make install
Creating directory /usr/local/bin/python3/bin
Creating directory /usr/local/bin/python3/lib
if test "no-framework" = "no-framework" ; then \
        /usr/bin/install -c python /usr/local/bin/python3/bin/python3.8; \
else \
        /usr/bin/install -c -s Mac/pythonw /usr/local/bin/python3/bin/python3.8; \
fi
if test "3.8" != "3.8"; then \
        if test -f /usr/local/bin/python3/bin/python3.8 -o -h /usr/local/bin/python3/bin/python3.8; \
        then rm -f /usr/local/bin/python3/bin/python3.8; \
        fi; \
        (cd /usr/local/bin/python3/bin; ln python3.8 python3.8); \
fi
if test -f libpython3.8.a && test "no-framework" = "no-framework" ; then \
        if test -n "" ; then \
                /usr/bin/install -c -m 755  /usr/local/bin/python3/bin; \
        else \
                /usr/bin/install -c -m 755 libpython3.8.a /usr/local/bin/python3/lib/libpython3.8.a; \
                if test libpython3.8.a != libpython3.8.a; then \
                        (cd /usr/local/bin/python3/lib; ln -sf libpython3.8.a libpython3.8.a) \
                fi \
        fi; \
        if test -n ""; then \
                /usr/bin/install -c -m 755  /usr/local/bin/python3/lib/; \
        fi; \
else    true; \
fi
(中间省略……)
if test "x" != "x" ; then \
        rm -f /usr/local/bin/python3/bin/python3-32; \
        (cd /usr/local/bin/python3/bin; ln -s python3.8-32 python3-32) \
fi
rm -f /usr/local/bin/python3/share/man/man1/python3.1
(cd /usr/local/bin/python3/share/man/man1; ln -s python3.8.1 python3.1)
if test "xupgrade" != "xno"  ; then \
        case upgrade in \
                upgrade) ensurepip="--upgrade" ;; \
                install|*) ensurepip="" ;; \
        esac; \
         ./python -E -m ensurepip \
                $ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmpm7wlu92v
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-19.2.3 setuptools-41.2.0
2. 配置Python默认版本为3.8.0
[root@Server Python-3.8.0]# python3 -V           //查看系统默认Python的版本号
Python 3.6.8
[root@Server Python-3.8.0]# rm -rf /usr/bin/python3
[root@Server Python-3.8.0]# ln -s /usr/local/bin/python3/bin/python3 /usr/bin/python3                 //将系统默认的Python版本修改为3.8.0
[root@Server Python-3.8.0]# python3 -V           //查看升级后系统默认Python的版本号
Python 3.8.0
[root@Server Python-3.8.0]# python3
Python 3.8.0 (default, Oct 16 2019, 12:16:41)
[GCC 8.2.1 20180905 (Red Hat 8.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>quit()

你可能感兴趣的:(CentOS 8.0 升级Python版本到3.8.0)