如何安装python

windows安装

下载安装包

登录python官网

https://www.python.org/

点击downloads

在这里插入图片描述

置顶下载的是最新的python版本

如果想下载指定版本往下翻找

在这里插入图片描述

安装程序

点击即可下载,然后打开下载的exe程序

在这里插入图片描述

勾选添加pythonexec到path,也就是添加到环境变量

使用admin权限进行安装

选择customize installation自定义安装

在这里插入图片描述

默认全选,点击next

自定义安装路径,最好在数据盘的位置创建一个python-版本号的目录,

associate files with python (requires the 'py' launcher)
将文件与python关联(需要'py'启动器)
create shortcuts for installed applications
为已安装的应用程序创建快捷方式
add python to environment variables
将python添加到环境变量
precompile standard library
预编译标准库
download debugging symbols
下载调试符号
download debug binaries (requires vs 2017 or later)
下载调试二进制文件(需要vs 2017或更高版本)

在这里插入图片描述

点击安装等待安装完成

在这里插入图片描述

diable path length limit

关闭路径长度限制

可以关闭

然后就代表安装完成了

安装完后的验证操作

打开cmd,输入python,然后回车

在这里插入图片描述

此处就进入到了python的环境了。也有一个版本号介绍信息

linux安装python(编译安装)

先安装依赖环境程序

[root@iZbp1jf2qla2dgfn1anb4zZ ~]# yum install wget zilb-devel bzip2-devel openssl-devel ncurses-devel splite-devel readline-devel tk-devel gcc make zlib zlib-devel libffi-devel -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package wget-1.14-18.el7_6.1.x86_64 already installed and latest version
No package zilb-devel available.
No package splite-devel available.
Package gcc-4.8.5-44.el7.x86_64 already installed and latest version
Package 1:make-3.82-24.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package bzip2-devel.x86_64 0:1.0.6-13.el7 will be installed
---> Package libffi-devel.x86_64 0:3.0.13-19.el7 will be installed
---> 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
---> 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 zlib.x86_64 0:1.2.7-19.el7_9 will be updated
---> Package zlib.x86_64 0:1.2.7-20.el7_9 will be an update
---> Package zlib-devel.x86_64 0:1.2.7-20.el7_9 will be installed
--> Running transaction check
---> Package krb5-devel.x86_64 0:1.15.1-55.el7_9 will be installed
--> Processing Dependency: libkadm5(x86-64) = 1.15.1-55.el7_9 for package: krb5-devel-1.15.1-55.el7_9.x86_64
--> Processing Dependency: krb5-libs(x86-64) = 1.15.1-55.el7_9 for package: krb5-devel-1.15.1-55.el7_9.x86_64
--> Processing Dependency: libverto-devel for package: krb5-devel-1.15.1-55.el7_9.x86_64
--> Processing Dependency: libselinux-devel for package: krb5-devel-1.15.1-55.el7_9.x86_64
--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.15.1-55.el7_9.x86_64
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.15.1-55.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 openssl-libs.x86_64 1:1.0.2k-21.el7_9 will be updated
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-21.el7_9 for package: 1:openssl-1.0.2k-21.el7_9.x86_64
---> Package openssl-libs.x86_64 1:1.0.2k-25.el7_9 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
--> 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: 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-50.el7 will be updated
---> Package krb5-libs.x86_64 0:1.15.1-55.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
---> Package libkadm5.x86_64 0:1.15.1-55.el7_9 will be installed
---> Package libselinux-devel.x86_64 0:2.5-15.el7 will be installed
--> 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-21.el7_9 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-15.el7_9 will be installed
--> Processing Dependency: expat = 2.1.0-15.el7_9 for package: expat-devel-2.1.0-15.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 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 libpng-devel.x86_64 2:1.5.13-8.el7 will be installed
---> 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
---> 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 expat.x86_64 0:2.1.0-12.el7 will be updated
---> Package expat.x86_64 0:2.1.0-15.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
--> Running transaction check
---> Package dejavu-fonts-common.noarch 0:2.33-6.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================
 Package                           Arch             Version                         Repository         Size
============================================================================================================
Installing:
 bzip2-devel                       x86_64           1.0.6-13.el7                    base              218 k
 libffi-devel                      x86_64           3.0.13-19.el7                   base               23 k
 ncurses-devel                     x86_64           5.9-14.20130511.el7_4           base              712 k
 openssl-devel                     x86_64           1:1.0.2k-25.el7_9               updates           1.5 M
 readline-devel                    x86_64           6.2-11.el7                      base              139 k
 tk-devel                          x86_64           1:8.5.13-6.el7                  base              488 k
 zlib-devel                        x86_64           1.2.7-20.el7_9                  updates            50 k
Updating:
 zlib                              x86_64           1.2.7-20.el7_9                  updates            90 k
Installing for dependencies:
 dejavu-fonts-common               noarch           2.33-6.el7                      base               64 k
 dejavu-sans-fonts                 noarch           2.33-6.el7                      base              1.4 M
 expat-devel                       x86_64           2.1.0-15.el7_9                  updates            58 k
 fontconfig                        x86_64           2.13.0-4.3.el7                  base              254 k
 fontconfig-devel                  x86_64           2.13.0-4.3.el7                  base              138 k
 fontpackages-filesystem           noarch           1.44-8.el7                      base              9.9 k
 freetype-devel                    x86_64           2.8-14.el7_9.1                  updates           447 k
 keyutils-libs-devel               x86_64           1.5.8-3.el7                     base               37 k
 krb5-devel                        x86_64           1.15.1-55.el7_9                 updates           273 k
 libX11                            x86_64           1.6.7-4.el7_9                   updates           607 k
 libX11-common                     noarch           1.6.7-4.el7_9                   updates           164 k
 libX11-devel                      x86_64           1.6.7-4.el7_9                   updates           981 k
 libXau                            x86_64           1.0.8-2.1.el7                   base               29 k
 libXau-devel                      x86_64           1.0.8-2.1.el7                   base               14 k
 libXft                            x86_64           2.3.2-2.el7                     base               58 k
 libXft-devel                      x86_64           2.3.2-2.el7                     base               19 k
 libXrender                        x86_64           0.9.10-1.el7                    base               26 k
 libXrender-devel                  x86_64           0.9.10-1.el7                    base               17 k
 libcom_err-devel                  x86_64           1.42.9-19.el7                   base               32 k
 libkadm5                          x86_64           1.15.1-55.el7_9                 updates           180 k
 libpng-devel                      x86_64           2:1.5.13-8.el7                  base              122 k
 libselinux-devel                  x86_64           2.5-15.el7                      base              187 k
 libsepol-devel                    x86_64           2.5-10.el7                      base               77 k
 libuuid-devel                     x86_64           2.23.2-65.el7_9.1               updates            93 k
 libverto-devel                    x86_64           0.2.5-4.el7                     base               12 k
 libxcb                            x86_64           1.13-1.el7                      base              214 k
 libxcb-devel                      x86_64           1.13-1.el7                      base              1.1 M
 pcre-devel                        x86_64           8.32-17.el7                     base              480 k
 tcl                               x86_64           1:8.5.13-8.el7                  base              1.9 M
 tcl-devel                         x86_64           1:8.5.13-8.el7                  base              165 k
 tk                                x86_64           1:8.5.13-6.el7                  base              1.4 M
 xorg-x11-proto-devel              noarch           2018.4-1.el7                    base              280 k
Updating for dependencies:
 expat                             x86_64           2.1.0-15.el7_9                  updates            83 k
 krb5-libs                         x86_64           1.15.1-55.el7_9                 updates           810 k
 openssl                           x86_64           1:1.0.2k-25.el7_9               updates           494 k
 openssl-libs                      x86_64           1:1.0.2k-25.el7_9               updates           1.2 M

Transaction Summary
============================================================================================================
Install  7 Packages (+32 Dependent packages)
Upgrade  1 Package  (+ 4 Dependent packages)

Total size: 16 M
Total download size: 1.0 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/6): bzip2-devel-1.0.6-13.el7.x86_64.rpm                                           | 218 kB  00:00:00
(2/6): expat-2.1.0-15.el7_9.x86_64.rpm                                               |  83 kB  00:00:00
(3/6): libverto-devel-0.2.5-4.el7.x86_64.rpm                                         |  12 kB  00:00:00
(4/6): zlib-1.2.7-20.el7_9.x86_64.rpm                                                |  90 kB  00:00:00
(5/6): libkadm5-1.15.1-55.el7_9.x86_64.rpm                                           | 180 kB  00:00:00
(6/6): pcre-devel-8.32-17.el7.x86_64.rpm                                             | 480 kB  00:00:00
------------------------------------------------------------------------------------------------------------
Total                                                                       8.9 MB/s | 1.0 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : xorg-x11-proto-devel-2018.4-1.el7.noarch                                                1/49
  Updating   : zlib-1.2.7-20.el7_9.x86_64                                                              2/49
  Updating   : krb5-libs-1.15.1-55.el7_9.x86_64                                                        3/49
  Updating   : 1:openssl-libs-1.0.2k-25.el7_9.x86_64                                                   4/49
  Installing : zlib-devel-1.2.7-20.el7_9.x86_64                                                        5/49
  Installing : libXau-1.0.8-2.1.el7.x86_64                                                             6/49
  Installing : libxcb-1.13-1.el7.x86_64                                                                7/49
  Updating   : expat-2.1.0-15.el7_9.x86_64                                                             8/49
  Installing : fontpackages-filesystem-1.44-8.el7.noarch                                               9/49
  Installing : 1:tcl-8.5.13-8.el7.x86_64                                                              10/49
  Installing : 1:tcl-devel-8.5.13-8.el7.x86_64                                                        11/49
  Installing : dejavu-fonts-common-2.33-6.el7.noarch                                                  12/49
  Installing : dejavu-sans-fonts-2.33-6.el7.noarch                                                    13/49
  Installing : fontconfig-2.13.0-4.3.el7.x86_64                                                       14/49
  Installing : expat-devel-2.1.0-15.el7_9.x86_64                                                      15/49
  Installing : libXau-devel-1.0.8-2.1.el7.x86_64                                                      16/49
  Installing : libxcb-devel-1.13-1.el7.x86_64                                                         17/49
  Installing : 2:libpng-devel-1.5.13-8.el7.x86_64                                                     18/49
  Installing : freetype-devel-2.8-14.el7_9.1.x86_64                                                   19/49
  Installing : libkadm5-1.15.1-55.el7_9.x86_64                                                        20/49
  Installing : libcom_err-devel-1.42.9-19.el7.x86_64                                                  21/49
  Installing : libX11-common-1.6.7-4.el7_9.noarch                                                     22/49
  Installing : libX11-1.6.7-4.el7_9.x86_64                                                            23/49
  Installing : libXrender-0.9.10-1.el7.x86_64                                                         24/49
  Installing : libXft-2.3.2-2.el7.x86_64                                                              25/49
  Installing : libX11-devel-1.6.7-4.el7_9.x86_64                                                      26/49
  Installing : libXrender-devel-0.9.10-1.el7.x86_64                                                   27/49
  Installing : 1:tk-8.5.13-6.el7.x86_64                                                               28/49
  Installing : libsepol-devel-2.5-10.el7.x86_64                                                       29/49
  Installing : ncurses-devel-5.9-14.20130511.el7_4.x86_64                                             30/49
  Installing : pcre-devel-8.32-17.el7.x86_64                                                          31/49
  Installing : libselinux-devel-2.5-15.el7.x86_64                                                     32/49
  Installing : libverto-devel-0.2.5-4.el7.x86_64                                                      33/49
  Installing : libuuid-devel-2.23.2-65.el7_9.1.x86_64                                                 34/49
  Installing : fontconfig-devel-2.13.0-4.3.el7.x86_64                                                 35/49
  Installing : libXft-devel-2.3.2-2.el7.x86_64                                                        36/49
  Installing : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                 37/49
  Installing : krb5-devel-1.15.1-55.el7_9.x86_64                                                      38/49
  Installing : 1:openssl-devel-1.0.2k-25.el7_9.x86_64                                                 39/49
  Installing : 1:tk-devel-8.5.13-6.el7.x86_64                                                         40/49
  Installing : readline-devel-6.2-11.el7.x86_64                                                       41/49
  Updating   : 1:openssl-1.0.2k-25.el7_9.x86_64                                                       42/49
  Installing : bzip2-devel-1.0.6-13.el7.x86_64                                                        43/49
  Installing : libffi-devel-3.0.13-19.el7.x86_64                                                      44/49
  Cleanup    : 1:openssl-1.0.2k-21.el7_9.x86_64                                                       45/49
  Cleanup    : krb5-libs-1.15.1-50.el7.x86_64                                                         46/49
  Cleanup    : 1:openssl-libs-1.0.2k-21.el7_9.x86_64                                                  47/49
  Cleanup    : zlib-1.2.7-19.el7_9.x86_64                                                             48/49
  Cleanup    : expat-2.1.0-12.el7.x86_64                                                              49/49
  Verifying  : libXft-devel-2.3.2-2.el7.x86_64                                                         1/49
  Verifying  : dejavu-sans-fonts-2.33-6.el7.noarch                                                     2/49
  Verifying  : 1:tcl-8.5.13-8.el7.x86_64                                                               3/49
  Verifying  : libselinux-devel-2.5-15.el7.x86_64                                                      4/49
  Verifying  : fontconfig-2.13.0-4.3.el7.x86_64                                                        5/49
  Verifying  : libXrender-0.9.10-1.el7.x86_64                                                          6/49
  Verifying  : expat-devel-2.1.0-15.el7_9.x86_64                                                       7/49
  Verifying  : krb5-devel-1.15.1-55.el7_9.x86_64                                                       8/49
  Verifying  : xorg-x11-proto-devel-2018.4-1.el7.noarch                                                9/49
  Verifying  : libffi-devel-3.0.13-19.el7.x86_64                                                      10/49
  Verifying  : 2:libpng-devel-1.5.13-8.el7.x86_64                                                     11/49
  Verifying  : fontpackages-filesystem-1.44-8.el7.noarch                                              12/49
  Verifying  : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                 13/49
  Verifying  : bzip2-devel-1.0.6-13.el7.x86_64                                                        14/49
  Verifying  : fontconfig-devel-2.13.0-4.3.el7.x86_64                                                 15/49
  Verifying  : libuuid-devel-2.23.2-65.el7_9.1.x86_64                                                 16/49
  Verifying  : libverto-devel-0.2.5-4.el7.x86_64                                                      17/49
  Verifying  : pcre-devel-8.32-17.el7.x86_64                                                          18/49
  Verifying  : ncurses-devel-5.9-14.20130511.el7_4.x86_64                                             19/49
  Verifying  : dejavu-fonts-common-2.33-6.el7.noarch                                                  20/49
  Verifying  : libX11-devel-1.6.7-4.el7_9.x86_64                                                      21/49
  Verifying  : 1:tk-devel-8.5.13-6.el7.x86_64                                                         22/49
  Verifying  : libxcb-1.13-1.el7.x86_64                                                               23/49
  Verifying  : 1:tk-8.5.13-6.el7.x86_64                                                               24/49
  Verifying  : libXrender-devel-0.9.10-1.el7.x86_64                                                   25/49
  Verifying  : expat-2.1.0-15.el7_9.x86_64                                                            26/49
  Verifying  : 1:openssl-libs-1.0.2k-25.el7_9.x86_64                                                  27/49
  Verifying  : krb5-libs-1.15.1-55.el7_9.x86_64                                                       28/49
  Verifying  : libXft-2.3.2-2.el7.x86_64                                                              29/49
  Verifying  : zlib-1.2.7-20.el7_9.x86_64                                                             30/49
  Verifying  : 1:openssl-1.0.2k-25.el7_9.x86_64                                                       31/49
  Verifying  : zlib-devel-1.2.7-20.el7_9.x86_64                                                       32/49
  Verifying  : freetype-devel-2.8-14.el7_9.1.x86_64                                                   33/49
  Verifying  : libsepol-devel-2.5-10.el7.x86_64                                                       34/49
  Verifying  : readline-devel-6.2-11.el7.x86_64                                                       35/49
  Verifying  : libxcb-devel-1.13-1.el7.x86_64                                                         36/49
  Verifying  : 1:openssl-devel-1.0.2k-25.el7_9.x86_64                                                 37/49
  Verifying  : libkadm5-1.15.1-55.el7_9.x86_64                                                        38/49
  Verifying  : libX11-1.6.7-4.el7_9.x86_64                                                            39/49
  Verifying  : libX11-common-1.6.7-4.el7_9.noarch                                                     40/49
  Verifying  : libXau-1.0.8-2.1.el7.x86_64                                                            41/49
  Verifying  : libcom_err-devel-1.42.9-19.el7.x86_64                                                  42/49
  Verifying  : 1:tcl-devel-8.5.13-8.el7.x86_64                                                        43/49
  Verifying  : libXau-devel-1.0.8-2.1.el7.x86_64                                                      44/49
  Verifying  : zlib-1.2.7-19.el7_9.x86_64                                                             45/49
  Verifying  : expat-2.1.0-12.el7.x86_64                                                              46/49
  Verifying  : 1:openssl-1.0.2k-21.el7_9.x86_64                                                       47/49
  Verifying  : 1:openssl-libs-1.0.2k-21.el7_9.x86_64                                                  48/49
  Verifying  : krb5-libs-1.15.1-50.el7.x86_64                                                         49/49

Installed:
  bzip2-devel.x86_64 0:1.0.6-13.el7                       libffi-devel.x86_64 0:3.0.13-19.el7
  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                      tk-devel.x86_64 1:8.5.13-6.el7
  zlib-devel.x86_64 0:1.2.7-20.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-15.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-55.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             libkadm5.x86_64 0:1.15.1-55.el7_9
  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                  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:
  zlib.x86_64 0:1.2.7-20.el7_9

Dependency Updated:
  expat.x86_64 0:2.1.0-15.el7_9         krb5-libs.x86_64 0:1.15.1-55.el7_9 openssl.x86_64 1:1.0.2k-25.el7_9
  openssl-libs.x86_64 1:1.0.2k-25.el7_9

Complete!
[root@iZbp1jf2qla2dgfn1anb4zZ ~]#

安装程序

官网找到源码包,解压然后配置安装路径

官网下载后,放到服务器上

[root@iZbp1jf2qla2dgfn1anb4zZ ~]# cd /opt/gsy/
[root@iZbp1jf2qla2dgfn1anb4zZ gsy]# ls
Python-3.11.2.tgz
[root@iZbp1jf2qla2dgfn1anb4zZ gsy]# tar -xf Python-3.11.2.tgz
[root@iZbp1jf2qla2dgfn1anb4zZ gsy]#
[root@iZbp1jf2qla2dgfn1anb4zZ gsy]# ls
Python-3.11.2  Python-3.11.2.tgz
[root@iZbp1jf2qla2dgfn1anb4zZ gsy]# cd Python-3.11.2
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# ls
aclocal.m4    configure     Grammar     Lib      Makefile.pre.in  Objects  PCbuild        Python      Tools
config.guess  configure.ac  Include     LICENSE  Misc             Parser   Programs       README.rst
config.sub    Doc           install-sh  Mac      Modules          PC       pyconfig.h.in  setup.py
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]#


查看configure配置的时候的help参数

常用的配置一般就是–prefix=PREFIX指定安装目录

[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# ./configure --help
`configure' configures python 3.11 to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/python]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --enable-universalsdk[=SDKDIR]
                          create a universal binary build. SDKDIR specifies
                          which macOS SDK should be used to perform the build,
                          see Mac/README.rst. (default is no)
  --enable-framework[=INSTALLDIR]
                          create a Python.framework rather than a traditional
                          Unix install. optional INSTALLDIR specifies the
                          installation path. see Mac/README.rst (default is
                          no)
  --enable-wasm-dynamic-linking
                          Enable dynamic linking support for WebAssembly
                          (default is no)
  --enable-wasm-pthreads  Enable pthread emulation for WebAssembly (default is
                          no)
  --enable-shared         enable building a shared Python library (default is
                          no)
  --enable-profiling      enable C-level code profiling with gprof (default is
                          no)
  --enable-pystats        enable internal statistics gathering (default is no)
  --enable-optimizations  enable expensive, stable optimizations (PGO, etc.)
                          (default is no)
  --enable-loadable-sqlite-extensions
                          support loadable extensions in the sqlite3 module,
                          see Doc/library/sqlite3.rst (default is no)
  --enable-ipv6           enable ipv6 (with ipv4) support, see
                          Doc/library/socket.rst (default is yes if supported)
  --enable-big-digits[=15|30]
                          use big digits (30 or 15 bits) for Python longs
                          (default is 30)]
  --disable-test-modules  don't build nor install test modules

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-build-python=python3.11
                          path to build python binary for cross compiling
                          (default: _bootstrap_python or python3.11)
  --with-pkg-config=[yes|no|check]
                          use pkg-config to detect build options (default is
                          check)
  --with-universal-archs=ARCH
                          specify the kind of macOS universal binary that
                          should be created. This option is only valid when
                          --enable-universalsdk is set; options are:
                          ("universal2", "intel-64", "intel-32", "intel",
                          "32-bit", "64-bit", "3-way", or "all") see
                          Mac/README.rst
  --with-framework-name=FRAMEWORK
                          specify the name for the python framework on macOS
                          only valid when --enable-framework is set. see
                          Mac/README.rst (default is 'Python')
  --with-cxx-main[=COMPILER]
                          compile main() and link Python executable with C++
                          compiler specified in COMPILER (default is $CXX)
  --with-emscripten-target=[browser|node]
                          Emscripten platform
  --with-suffix=SUFFIX    set executable suffix to SUFFIX (default is empty,
                          yes is mapped to '.exe')
  --without-static-libpython
                          do not build libpythonMAJOR.MINOR.a and do not
                          install python.o (default is yes)
  --with-pydebug          build with Py_DEBUG defined (default is no)
  --with-trace-refs       enable tracing references for debugging purpose
                          (default is no)
  --with-assertions       build with C assertions enabled (default is no)
  --with-lto=[full|thin|no|yes]
                          enable Link-Time-Optimization in any build (default
                          is no)
  --with-address-sanitizer
                          enable AddressSanitizer memory error detector,
                          'asan' (default is no)
  --with-memory-sanitizer enable MemorySanitizer allocation error detector,
                          'msan' (default is no)
  --with-undefined-behavior-sanitizer
                          enable UndefinedBehaviorSanitizer undefined
                          behaviour detector, 'ubsan' (default is no)
  --with-hash-algorithm=[fnv|siphash13|siphash24]
                          select hash algorithm for use in Python/pyhash.c
                          (default is SipHash13)
  --with-tzpath=<list of absolute paths separated by pathsep>
                           Select the default time zone search path for zoneinfo.TZPATH

  --with-libs='lib1 ...'  link against additional libs (default is no)
  --with-system-expat     build pyexpat module using an installed expat
                          library, see Doc/library/pyexpat.rst (default is no)
  --with-system-ffi       build _ctypes module using an installed ffi library,
                          see Doc/library/ctypes.rst (default is
                          system-dependent)
  --with-system-libmpdec  build _decimal module using an installed libmpdec
                          library, see Doc/library/decimal.rst (default is no)
  --with-decimal-contextvar
                          build _decimal module using a coroutine-local rather
                          than a thread-local context (default is yes)
  --with-dbmliborder=db1:db2:...
                          override order to check db backends for dbm; a valid
                          value is a colon separated string with the backend
                          names `ndbm', `gdbm' and `bdb'.
  --with-doc-strings      enable documentation strings (default is yes)
  --with-pymalloc         enable specialized mallocs (default is yes)
  --with-freelists        enable object freelists (default is yes)
  --with-c-locale-coercion
                          enable C locale coercion to a UTF-8 based locale
                          (default is yes)
  --with-valgrind         enable Valgrind support (default is no)
  --with-dtrace           enable DTrace support (default is no)
  --with-libm=STRING      override libm math library to STRING (default is
                          system-dependent)
  --with-libc=STRING      override libc C library to STRING (default is
                          system-dependent)
  --with-platlibdir=DIRNAME
                          Python library directory name (default is "lib")
  --with-wheel-pkg-dir=PATH
                          Directory of wheel packages used by ensurepip
                          (default: none)
  --with(out)-readline[=editline]
                          use Editline for backend or disable readline module
  --with-computed-gotos   enable computed gotos in evaluation loop (enabled by
                          default on supported compilers)
  --with-ensurepip[=install|upgrade|no]
                          "install" or "upgrade" using bundled pip (default is
                          upgrade)
  --with-openssl=DIR      root of the OpenSSL directory
  --with-openssl-rpath=[DIR|auto|no]
                          Set runtime library directory (rpath) for OpenSSL
                          libraries, no (default): don't set rpath, auto:
                          auto-detect rpath from --with-openssl and
                          pkg-config, DIR: set an explicit rpath
  --with-ssl-default-suites=[python|openssl|STRING]
                          override default cipher suites string, python: use
                          Python's preferred selection (default), openssl:
                          leave OpenSSL's defaults untouched, STRING: use a
                          custom string, python and STRING also set TLS 1.2 as
                          minimum TLS version
  --with-builtin-hashlib-hashes=md5,sha1,sha256,sha512,sha3,blake2
                          builtin hash modules, md5, sha1, sha256, sha512,
                          sha3 (with shake), blake2

Some influential environment variables:
  PKG_CONFIG  path to pkg-config utility
  PKG_CONFIG_PATH
              directories to add to pkg-config's search path
  PKG_CONFIG_LIBDIR
              path overriding pkg-config's built-in search path
  MACHDEP     name for machine-dependent library files
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  HOSTRUNNER  Program to run CPython for the host platform
  PROFILE_TASK
              Python args for PGO generation task
  LIBUUID_CFLAGS
              C compiler flags for LIBUUID, overriding pkg-config
  LIBUUID_LIBS
              linker flags for LIBUUID, overriding pkg-config
  LIBNSL_CFLAGS
              C compiler flags for LIBNSL, overriding pkg-config
  LIBNSL_LIBS linker flags for LIBNSL, overriding pkg-config
  LIBSQLITE3_CFLAGS
              C compiler flags for LIBSQLITE3, overriding pkg-config
  LIBSQLITE3_LIBS
              linker flags for LIBSQLITE3, overriding pkg-config
  TCLTK_CFLAGS
              C compiler flags for TCLTK, overriding pkg-config
  TCLTK_LIBS  linker flags for TCLTK, overriding pkg-config
  X11_CFLAGS  C compiler flags for X11, overriding pkg-config
  X11_LIBS    linker flags for X11, overriding pkg-config
  GDBM_CFLAGS C compiler flags for gdbm
  GDBM_LIBS   additional linker flags for gdbm
  ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config
  ZLIB_LIBS   linker flags for ZLIB, overriding pkg-config
  BZIP2_CFLAGS
              C compiler flags for BZIP2, overriding pkg-config
  BZIP2_LIBS  linker flags for BZIP2, overriding pkg-config
  LIBLZMA_CFLAGS
              C compiler flags for LIBLZMA, overriding pkg-config
  LIBLZMA_LIBS
              linker flags for LIBLZMA, overriding pkg-config
  LIBCRYPT_CFLAGS
              C compiler flags for LIBCRYPT, overriding pkg-config
  LIBCRYPT_LIBS
              linker flags for LIBCRYPT, overriding pkg-config
  LIBB2_CFLAGS
              C compiler flags for LIBB2, overriding pkg-config
  LIBB2_LIBS  linker flags for LIBB2, overriding pkg-config

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to <https://github.com/python/cpython/issues/>.
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]#

[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# ./configure  --prefix=/usr/local/python-3.11.2
。。。
checking for stdlib extension module xxlimited_35... 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/Setup.bootstrap
config.status: creating Modules/Setup.stdlib
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
configure: creating Modules/Setup.local
configure: creating Makefile
configure:

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

[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# ls
aclocal.m4     config.sub    Grammar     LICENSE       Makefile.pre.in  Parser    pyconfig.h     setup.py
config.guess   configure     Include     Mac           Misc             PC        pyconfig.h.in  Tools
config.log     configure.ac  install-sh  Makefile      Modules          PCbuild   Python
config.status  Doc           Lib         Makefile.pre  Objects          Programs  README.rst
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]#

然后make && make install

Looking in links: /tmp/tmpgxoxt08n
Processing /tmp/tmpgxoxt08n/setuptools-65.5.0-py3-none-any.whl
Processing /tmp/tmpgxoxt08n/pip-22.3.1-py3-none-any.whl
Installing collected packages: setuptools, pip
  WARNING: The scripts pip3 and pip3.11 are installed in '/usr/local/python-3.11.2/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-22.3.1 setuptools-65.5.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# ls /usr/local/python-3.11.2/
bin  include  lib  share

验证

查看,python3.11就是执行命令程序

[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# ls -slahrt /usr/local/python-3.11.2/bin/
total 24M
 24M -rwxr-xr-x 1 root root  24M Mar  6 11:28 python3.11
4.0K -rwxr-xr-x 1 root root   99 Mar  6 11:28 pydoc3.11
4.0K -rwxr-xr-x 1 root root  114 Mar  6 11:28 idle3.11
4.0K -rwxr-xr-x 1 root root  116 Mar  6 11:28 2to3-3.11
4.0K -rwxr-xr-x 1 root root 3.0K Mar  6 11:28 python3.11-config
4.0K drwxr-xr-x 6 root root 4.0K Mar  6 11:28 ..
   0 lrwxrwxrwx 1 root root   10 Mar  6 11:28 python3 -> python3.11
   0 lrwxrwxrwx 1 root root   17 Mar  6 11:28 python3-config -> python3.11-config
   0 lrwxrwxrwx 1 root root    8 Mar  6 11:28 idle3 -> idle3.11
   0 lrwxrwxrwx 1 root root    9 Mar  6 11:28 pydoc3 -> pydoc3.11
   0 lrwxrwxrwx 1 root root    9 Mar  6 11:28 2to3 -> 2to3-3.11
4.0K -rwxr-xr-x 1 root root  244 Mar  6 11:28 pip3.11
4.0K -rwxr-xr-x 1 root root  244 Mar  6 11:28 pip3
4.0K drwxr-xr-x 2 root root 4.0K Mar  6 11:28 .

linux默认有一个python2.7的版本

可以删掉然后创建一个软连接过去,或者配置全局变量让环境识别到python3.11

临时配置全局变量识别python3

[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# python3.11
-bash: python3.11: command not found
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# PATH=$PATH:/usr/local/python-3.11.2/bin/
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/python-3.11.2/bin/
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# python3.11
Python 3.11.2 (main, Mar  6 2023, 11:26:58) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

永久配置的话写在profile里面即可

创建软连接让服务器识别python3

取消临时环境变量,再使用创建软连接的方法测试,不过此方法会让使用python2.7的脚本调用绝对路径

检查现有的软连接

[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# which python
/usr/bin/python
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# ls -alrht /usr/bin/python
lrwxrwxrwx 1 root root 7 Jan 28  2021 /usr/bin/python -> python2
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# which python2
/usr/bin/python2
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# ls -alrht /usr/bin/python2
lrwxrwxrwx 1 root root 9 Jan 28  2021 /usr/bin/python2 -> python2.7
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# which python2.7
/usr/bin/python2.7
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# ls -alrht /usr/bin/python2.7
-rwxr-xr-x 1 root root 7.0K Nov 17  2020 /usr/bin/python2.7
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]#

删掉然后创建一个软连接过去

[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# rm -rf /usr/bin/python
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# pwd
/opt/gsy/Python-3.11.2
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# ls
aclocal.m4         configure     libpython3.11.a  Modules   pybuilddir.txt    python-gdb.py
_bootstrap_python  configure.ac  LICENSE          Objects   pyconfig.h        README.rst
build              Doc           Mac              Parser    pyconfig.h.in     setup.py
config.guess       Grammar       Makefile         PC        python            Tools
config.log         Include       Makefile.pre     PCbuild   Python
config.status      install-sh    Makefile.pre.in  platform  python-config
config.sub         Lib           Misc             Programs  python-config.py
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# ln -s /usr/local/python-3.11.2/bi                                                                           n/py
pydoc3             python3            python3.11-config
pydoc3.11          python3.11         python3-config
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# ln -s /usr/local/python-3.11.2/bi                                                                           n/py
pydoc3             python3            python3.11-config
pydoc3.11          python3.11         python3-config
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# ln -s /usr/local/python-3.11.2/bi                                                                           n/python3.11 /usr/bin/python
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# ls -alrht /usr/bin/python
lrwxrwxrwx 1 root root 39 Mar  6 14:47 /usr/bin/python -> /usr/local/python-3.11.2/bin/python3.11
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# ls -alrht /usr/bin/python2
lrwxrwxrwx 1 root root 9 Jan 28  2021 /usr/bin/python2 -> python2.7
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]#

检查python版本

[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# vim /usr/libexec/urlgrabber-ext-down[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# python
Python 3.11.2 (main, Mar  6 2023, 11:26:58) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]#
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# python2
Python 2.7.5 (default, Nov 16 2020, 22:23:17)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# python3.11
Python 3.11.2 (main, Mar  6 2023, 11:26:58) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

更新依赖pthon2的yum

[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# vim /usr/libexec/urlgrabber-ext-down
#! /usr/bin/python2      #改成python2
然后保存退出
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# yum list
  File "/usr/bin/yum", line 30
    except KeyboardInterrupt, e:
           ^^^^^^^^^^^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized


[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]#vim /usr/bin/yum
#!/usr/bin/python2  # 改成python2
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# yum list  | head -n 10
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
NetworkManager.x86_64                    1:1.18.8-2.el7_9              @updates
NetworkManager-libnm.x86_64              1:1.18.8-2.el7_9              @updates
NetworkManager-team.x86_64               1:1.18.8-2.el7_9              @updates
NetworkManager-tui.x86_64                1:1.18.8-2.el7_9              @updates
NetworkManager-wifi.x86_64               1:1.18.8-2.el7_9              @updates
acl.x86_64                               2.2.51-15.el7                 @anaconda
aic94xx-firmware.noarch                  30-6.el7                      @anaconda



ltiple exception types must be parenthesized

[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]#vim /usr/bin/yum
#!/usr/bin/python2 # 改成python2
[root@iZbp1jf2qla2dgfn1anb4zZ Python-3.11.2]# yum list | head -n 10
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
NetworkManager.x86_64 1:1.18.8-2.el7_9 @updates
NetworkManager-libnm.x86_64 1:1.18.8-2.el7_9 @updates
NetworkManager-team.x86_64 1:1.18.8-2.el7_9 @updates
NetworkManager-tui.x86_64 1:1.18.8-2.el7_9 @updates
NetworkManager-wifi.x86_64 1:1.18.8-2.el7_9 @updates
acl.x86_64 2.2.51-15.el7 @anaconda
aic94xx-firmware.noarch 30-6.el7 @anaconda




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值