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=<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 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()
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,922评论 6 497
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,591评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,546评论 0 350
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,467评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,553评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,580评论 1 293
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,588评论 3 414
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,334评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,780评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,092评论 2 330
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,270评论 1 344
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,925评论 5 338
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,573评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,194评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,437评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,154评论 2 366
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,127评论 2 352

推荐阅读更多精彩内容

  • feisky云计算、虚拟化与Linux技术笔记posts - 1014, comments - 298, trac...
    不排版阅读 3,842评论 0 5
  • 一、Python简介和环境搭建以及pip的安装 4课时实验课主要内容 【Python简介】: Python 是一个...
    _小老虎_阅读 5,738评论 0 10
  • 摘要:以黑箱方式完全依赖工具来进行数据恢复,所需时间和恢复的结果都难以估计。以专家或者专业方式进行数据恢复,技能和...
    暖夏未眠丶阅读 950评论 0 3
  • 希望以后的我们也能把架吵的软绵绵,香喷喷。 最近看到一篇文章,里面有这么句话让我印象深刻。男人其实可以分为四...
    伊雪112阅读 170评论 0 0
  • ‘ 看过一个小视频。讲的是一个上门女婿多次遭受家庭暴力,遍体鳞伤,.仍坚持参与唱歌选秀的故事。该男子每次参与...
    琴韵诗心阅读 1,049评论 8 15