如何安装python

news2024/11/15 9:21:24

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




本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/391644.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Vue2.0开发之——购物车案例-Footer组件封装-计算商品的总价格(51)

一 概述 App.vue中计算勾选商品的总价格定义子组件Footer中的商品总价格将App.vue中商品的总价格传递给Footer显示 二 App.vue中计算勾选商品的总价格 2.1 商品总价格的计算逻辑 所有勾选商品的价格*数量 2.2 App.vue中通过计算属性计算总价格 通过计算属性计算总价格 co…

esp8266WiFi模块通过MQTT连接华为云

esp8266WiFi模块通过MQTT连接华为云总结&#xff1a;一、 MQTT透传AT固件烧录二、 串口调试2.1 设置模块为STA模式2.2 连接WiFi2.3 设置MQTT的登陆用户名与密码2.4 设置MQTT的ClientID2.5 设置MQTT接入地址2.6 订阅设备属性上报的主题2.7 上传数据2.8 平台下发命令2.9 华为云物…

网络编程学习笔记(1)--TCP/IP协议基础

目录 全称 定义 分层结构 端到端的数据传输 ​编辑 举个栗子——浏览网页 应用层 传输层 TCP UDP 网络层 IP协议 特点 IP地址 网络掩码 ARP协议 PARP协议 ICMP协议 数据链路层 名词解释 数据段 数据报 数据包 数据帧 比特流 全称 Transmission Contro…

关于进制的转换

将n进制转化为m进制一般&#xff0c;我们是通过位值定理来将n进制转化为10进制&#xff1b;然后对整数进行辗转相除来得到m进制整数void find(int x){//integer; w0;while(sum>0){ //先除为低&#xff1b; t[w]q[sum%m];w;sum/m;}markw; }for(int ik-1,j0;i>0;i--,j){//i…

Linux操作系统学习(线程基础)

文章目录线程的基础概念线程控制内核LWP和线程ID的关系线程的基础概念 ​ 一般教材对线程描述是&#xff1a;是在进程内部运行的一个分支&#xff08;执行流&#xff09;&#xff0c;属于进程的一部分&#xff0c;粒度要比进程更加细和轻量化 ​ 一个进程中是可能存在多个线程…

【Java|golang】1653. 使字符串平衡的最少删除次数---动态规划

给你一个字符串 s &#xff0c;它仅包含字符 ‘a’ 和 b’​​​​ 。 你可以删除 s 中任意数目的字符&#xff0c;使得 s 平衡 。当不存在下标对 (i,j) 满足 i < j &#xff0c;且 s[i] ‘b’ 的同时 s[j] ‘a’ &#xff0c;此时认为 s 是 平衡 的。 请你返回使 s 平衡…

亚马逊、速卖通、lazada店铺一直不出单,没流量怎么办?

近几年&#xff0c;跨境电商入驻的卖家越来越多&#xff0c;平台的流量越来越分散&#xff0c;导致店铺没有流量没有订单的情况经常发生&#xff0c;因此卖家对店铺的优化尤为主要。 对于亚马逊卖家来说&#xff0c;几乎每天都会问虽然我把我的产品放在货架上&#xff0c;但没…

4N60-ASEMI高压MOS管4N60

编辑-Z 4N60在TO-220封装里的静态漏极源导通电阻&#xff08;RDS(ON)&#xff09;为2.5Ω&#xff0c;是一款N沟道高压MOS管。4N60的最大脉冲正向电流ISM为16A&#xff0c;零栅极电压漏极电流(IDSS)为1uA&#xff0c;其工作时耐温度范围为-55~150摄氏度。4N60功耗&#xff08;…

Vue基础17之配置代理

Vue基础17配置代理使用node启动两台服务器server1.jsserver2.js使用axios发送ajax请求安装axios库引入axios库发送axios请求App.vue跨域问题解决代理服务器开启&#xff1a;方式一代理服务器开启&#xff1a;方式二server1.jsserver2.jsvue.config.jsApp.vue总结&#xff1a;Vu…

面向对象设计模式:结构型模式之代理模式

一、引入 访问 FB&#xff1a;代理服务器 二、代理模式 aka Surrogate 2.1 Intent 意图 Provide a surrogate (代理) or placeholder for another object to control access to it. 为另一个对象提供一个代理或占位符&#xff0c;以控制对它的访问。代理模式给某一个对象提…

2023年如何在Google做外贸

2023年如何在Google做外贸 答案是&#xff1a;利用谷歌SEO获取自然流量促进成交。 随着全球化和数字化的发展&#xff0c;外贸行业越来越重视互联网的渠道拓展。 在Google搜索引擎上做好SEO优化&#xff0c;是吸引国际客户和提高品牌知名度的关键。 本文将探讨2023年如何在…

【容器运行时】一文理解 OCI、runc、containerd、docker、shim进程、cri、kubelet 之间的关系

参考 docker&#xff0c;containerd&#xff0c;runc&#xff0c;docker-shim 之间的关系Containerd shim 进程 PPID 之谜内核大神教你从 Linux 进程的角度看 DockerRunC 简介OCI和runCContainerd 简介从 docker 到 runCDockershim究竟是什么技术干货&#xff5c;Docker和 Con…

C# 中的abstract和virtual

重新理解了下关键字abstract,做出以下总结&#xff1a; 1.标记为abstract的类不能实例化&#xff0c;但是依然可以有构造函数&#xff0c;也可以重载构造函数&#xff0c;在子类中调用 2.abstract类中可以有abstract标记的方法和属性&#xff0c;也可以没有&#xff0c;被标记…

Linux网络编程学习(网络基础)

文章目录网络基础浅谈计算机网络背景了解协议网络传输基本流程局域网传输基本流程跨网络的数据传输流程网络基础 浅谈计算机网络背景 ​ 计算机最早是没有网络的&#xff0c;当时想要数据之间交互就需要人来传递&#xff0c;但是这样效率非常低&#xff0c;而且也容易出错&am…

机器人姿态规划的三种常见方法:欧拉角、角轴和四元数

参考文献&#xff1a; 1. 布鲁诺西西里安诺等[意] 《机器人学&#xff1a;建模、规划与控制》 2. 四元数小总结 - 孤独の巡礼 - 博客园 (cnblogs.com) 3. 基于单位四元数的姿态插补&#xff08;Matlab&#xff09; - 知乎 (zhihu.com) 4. 基于四元数的工业机器人姿态规划与插…

javaScript基础面试题 --- JS作用域

面试10家公司&#xff0c;得有8家会问到作用域的题。所以说JS的作用域一定要弄清楚&#xff0c;非常重要&#xff01; 1、除了函数之外&#xff0c;JS没有块级作用域 2、作用域链&#xff1a;内部可以访问外部的变量&#xff0c;但是外部不能访问内部变量&#xff0c;如果内部有…

Docker搭建jenkins(Vue自动化部署)

前言 需要提前准备的条件 Docker环境 一、jenkins镜像 # 查询镜像 docker search jenkins# 下载镜像 # lts稳定版 docker pull jenkins/jenkins:lts#查看镜像 docker images二、启动Jenkins容器 创建挂载文件夹&#xff0c;并且进行文件授予权限 #创建文件夹 mkdir -p /home/j…

2023年湖北武汉初级、中级工程师职称评审条件和评审流程是什么呢?

职称分三个级别&#xff1a;初级、中级、高级&#xff0c;原则是需要一级一级的&#xff0c;但是有的地方可以跨级申报。 一、湖北武汉初级、中级工程师职称评定条件&#xff1a; 助理职称评定条件&#xff1a; 1.大学本科毕业&#xff0c;从事专业技术工作1年以上。 2.大学专…

Java Web 实战 02 - 多线程基础篇(1)

Java Web 实战 02 - 多线程基础篇 - 1一 . 认识线程1.1 概念1.1.1 什么是线程?1.1.2 为什么要有多个线程?1.1.3 进程和线程的区别(面试题)1.2 第一个多线程程序1.3 创建线程1.3.1 继承Thread类1.3.2 实现Runnable接口1.3.3 继承 Thread 类 , 使用匿名内部类1.3.4 实现 Runnab…

Linux嵌入式开发 | 汇编驱动LED(1)

文章目录&#x1f697; &#x1f697;Linux嵌入式开发 | 汇编驱动LED&#xff08;1&#xff09;&#x1f697; &#x1f697;初始化IO&#x1f697; &#x1f697;STM32&#x1f697; &#x1f697;使能GPIO时钟&#x1f697; &#x1f697;设置IO复用&#x1f697; &#x1f6…