SUSE_Enterprise Server 12 SP4_Python安装升级


目标

从python3.4.6 升级到python 3.9   pip升级到3.9

1. 查看系统中已经安装的python信息

# zypper se python

# rpm -qa | grep python

# python --version

# python3 --version 

2.查看pip是否安装

 # pip --version 

3.安装python3版本pip

因为通过第1步骤,确认已经安装python的版本是python3.4.6,所以集成了pip,可以通过下述命令来启用pip

 # python3 -m ensurepip --default-pip 

4.配置zypper国内源为清华大学源

# zypper addrepo -f https://mirrors.tuna.tsinghua.edu.cn/opensuse/distribution/leap/15.3/repo/oss/  tsinghurepo
# zypper lr

5.安装python3.9

# zypper se python39
# zipper install  python39

安装过程中,提示文件冲突,确认是否覆盖,yes

安装完成后,如有如下提示:

There are some running programs that might use files deleted by recent upgrade. You may wish to check and restart some of them. Run 'zypper ps -s' to list these programs.

按照提示查看一下,需要重启的应用。

6.查看新安装的python版本

  # python3.9 -V 

7.启用pytho39自带的pip工具

# python3.9 -m ensurepip --default-pip

# pip3 --version 

8 .配置python3.9源为国内清华源:

需要确保网络pypi.tuna.tsinghua.edu.cn主机可以ping通

# pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

9.查看 python安装目录

# rpm  -ql  python39
# rpm –ql  python39-base