首页 > 系统相关 >Yum系列系统升级python版本

Yum系列系统升级python版本

时间:2023-02-20 18:58:40浏览次数:63  
标签:系统升级 python devel Windows Yum root python3 3.9

问题描述

系统可能携带的是python3.6,而自动化开发基线是python3.7就会导致部分包无法使用等问题

升级python3.7

  1. 查看当前系统python版本

    ls -al /usr/bin |grep python
    

    输出:

    [uos@localhost ~]$ ls -al /usr/bin |grep python
    lrwxrwxrwx  1 root root          31 11月 30  2021 python3 -> /usr/libexec/platform-python3.6
    lrwxrwxrwx  1 root root          32 11月 30  2021 python3.6m -> /usr/libexec/platform-python3.6m
    lrwxrwxrwx  1 root root          25  2月 20 09:54 python3.bak -> /etc/alternatives/python3
    lrwxrwxrwx  1 root root          24  2月 20 09:54 unversioned-python -> /etc/alternatives/python
    

    基本说明python3版本是python3.6了

  2. 下载目标版本python3.7 tar包

    官方地址找到你要升级的版本点击download ,鼠标往下拉,找到 Files:

    Files

    Version Operating System Description MD5 Sum File Size GPG
    Gzipped source tarball Source release 2ee10f25e3d1b14215d56c3882486fcf 22973527 SIG
    XZ compressed source tarball Source release 93df27aec0cd18d6d42173e601ffbbfd 17108364 SIG
    macOS 64-bit/32-bit installer macOS for Mac OS X 10.6 and later 5a95572715e0d600de28d6232c656954 34479513 SIG
    macOS 64-bit installer macOS for OS X 10.9 and later 4ca0e30f48be690bfe80111daee9509a 27839889 SIG
    Windows help file Windows 7740b11d249bca16364f4a45b40c5676 8090273 SIG
    Windows x86-64 embeddable zip file Windows for AMD64/EM64T/x64 854ac011983b4c799379a3baa3a040ec 7018568 SIG
    Windows x86-64 executable installer Windows for AMD64/EM64T/x64 a2b79563476e9aa47f11899a53349383 26190920 SIG
    Windows x86-64 web-based installer Windows for AMD64/EM64T/x64 047d19d2569c963b8253a9b2e52395ef 1362888 SIG
    Windows x86 embeddable zip file Windows 70df01e7b0c1b7042aabb5a3c1e2fbd5 6526486 SIG
    Windows x86 executable installer Windows ebf1644cdc1eeeebacc92afa949cfc01 25424128 SIG
    Windows x86 web-based installer Windows d3944e218a45d982f0abcd93b151273a 1324632 SIG

    选择第一个 Gzipped source tarball 点击下载到本机

  3. 解压tar包(我这里下载了高版本3.9)

    [uos@localhost Desktop]$ tar -zxvf Python-3.9.6.tgz 
    

    在当前目录会出现一个Python-3.9.6目录,进入该目录

    [uos@localhost Desktop]$ cd Python-3.9.6/
    

    在当前目录执行:

    [uos@localhost Python-3.9.6]$ ./configure 
    
  4. 安装一些编译依赖,直接切换到root用户执行

    yum -y groupinstall "Development tools"
    yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
    yum install libffi-devel -y
    
  5. 开始编译:

    [uos@localhost Python-3.9.6]$ make
    
  6. 开始安装

    [uos@localhost Python-3.9.6]$ make install
    
  7. 这个时候直接执行python3,可能就已经是python3.9版本了(目前我的就是),如果还是python3.6继续第8步

  8. 修改/usr/bin/python3 指向的软连接到第三步解压出来的python

    先删除或者重命名原来的/usr/bin/python3

    [root@localhost Python-3.9.6]# mv /usr/bin/python3 /usr/bin/python3.bak
    

    新建/usr/bin/python3软连接

    [root@localhost Python-3.9.6]# ln -s /home/uos/Desktop/Python-3.9.6/python /usr/bin/python3
    
    

    查看一下:

    [root@localhost bin]# ls -al |grep python
    lrwxrwxrwx  1 root root          37  2月 20 18:36 python3 -> /home/uos/Desktop/Python-3.9.6/python
    lrwxrwxrwx  1 root root          31 11月 30  2021 python3.6 -> /usr/libexec/platform-python3.6
    lrwxrwxrwx  1 root root          32 11月 30  2021 python3.6m -> /usr/libexec/platform-python3.6m
    lrwxrwxrwx  1 root root          25  2月 20 09:54 python3.bak -> /etc/alternatives/python3
    lrwxrwxrwx  1 root root          29  2月 20 18:04 python3.bak1 -> /home/uos/Python-3.9.6/python
    lrwxrwxrwx  1 root root          24  2月 20 09:54 unversioned-python -> /etc/alternatives/python
    

    执行一下python3

    [root@localhost bin]# python3
    Python 3.9.6 (default, Feb 20 2023, 17:52:09) 
    [GCC 8.5.0 20210514 (UnionTech 8.5.0-10.0.3)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
    

标签:系统升级,python,devel,Windows,Yum,root,python3,3.9
From: https://www.cnblogs.com/tarzen213/p/17138504.html

相关文章

  • PYTHON将图片插入到excel
    一、案例1:insert_imageimportxlsxwriterbook=xlsxwriter.Workbook('E:\\test.xlsx')sheet=book.add_worksheet('demo')sheet.insert_image('D4','E:\\001.jpg')b......
  • python如何读取excel表数据
    @目录python读取excel表数据的方法:完整的程序代码python读取excel表数据的方法:首先安装Excel读取数据的库xlrd;然后获取Excel文件的位置并且读取进来;接着读取指定的行和列......
  • python 装饰器示例
    1defwrapper_log(func):2"""3无参装饰器,也可以写成有参装饰器,True或Flase标记是否调用日志模块4功能一:执行失败,打印并记录错误日志信息,定位bug......
  • python--matplotlib(2)
    前言 Matplotlib画图工具的官网地址是http://matplotlib.org/Python环境下实现Matlab制图功能的第三方库,需要numpy库的支持,支持用户方便设计出二维、三维数据的图形显示,制......
  • python之路73 vue框架 vue-cli创建项目、vue项目目录介绍、es6导入导出语法、登录功
    vue-cli创建项目前端做成项目---》使用工具(vue-cli),创建vue项目,单页面应用(spa),组件开发,把xx.vue,ts,saas,less---》编译---》在浏览器中执行vue-cli创建项目开发,在项......
  • python 获取b站 个人关注列表用户信息
    前言本程序是get_bili_medal_list项目的一个子程序,用于获取个人关注列表用户信息。整体很简单,没啥东西,主要是辅助作用。数据获取完毕后,存储于data/follows.json(提前......
  • python爬虫学习——文件操作,异常处理
    文件操作'''f=open("a.txt","w")#打开一个文件,w模式(写),如果文件不存在就在当前目录下创建f.write("helloworld,iamhere")#将字符串写入文件中f.cl......
  • python 实现 短信登录 b站 并打印cookie内容
    前言本程序是get_bili_medal_list项目的一个子程序,用于大批量获取用户数据时的cookie替换。使用项目根目录运行pythonlogin_get_cookie.py,根据提示完成短信验证登录。......
  • Python之装饰器的使用
    1.装饰器的使用场景函数执行时间的统计输出日志信息2.装饰器实现已有函数执行时间的统计importtime#装饰器函数defget_time(func):definner():begin=ti......
  • Python语言中变量名是什么?命名规则有哪些?
    在Python程序中,变量是用一个变量名表示,变量名必须是大小写英文、数字和下划线的组合,且不能用数字开头。那么Python语言中变量名是什么?变量的命名规则有哪些?具体内容请......