zoukankan      html  css  js  c++  java
  • 升级系统的python程序

    作者:邓聪聪

    1.检查确认系统的相关信息

    [root@test ~]# Linux test_server 3.10.0-957.12.2.el7.x86_64 #1 SMP Tue May 14 21:24:32 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
    [root@test ~]# python -V
    Python 2.7

    2.下载安装Python-3.6.2

    [root@test ~]# cd /usr/local/tools/
    [root@test tools]# wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
    [root@test tools]# ll
    total 22056
    drwxr-xr-x 17  501  501     4096 Jun 20 20:31 Python-3.6.2
    -rw-r--r--  1 root root 22580749 Jul 17  2017 Python-3.6.2.tgz

    1)编译并安装,下载编译必备的插件

    [root@test tools]#yum install make gcc gcc-c++ 
    [root@test tools]# cd Python-3.6.2
    [root@test tools]# ./configure
    [root@test tools]# make -j 2 && make install
    [root@test tools]#echo $?
    0  //为0表示成功

    2) 安装完成,需要更改默认的python版本

    # 检查当前默认的python2,默认自带的python位置在”/usr/bin/“目录下
    [root@test Python-3.6.2]# ll /usr/bin/python*
    -rwxr-xr-x  2 root root 9032 11月 22 2013 /usr/bin/python
    lrwxrwxrwx. 1 root root    6 3月  20 2016 /usr/bin/python2 -> python
    -rwxr-xr-x  2 root root 9032 11月 22 2013 /usr/bin/python2.6
    # 检查新安装的python3,默认编译安装的python位置在”/usr/local/bin/“目录下
    [root@test Python-3.6.2]# ll /usr/local/bin/python*
    lrwxrwxrwx 1 root root       9 10月 31 16:48 /usr/local/bin/python3 -> python3.6
    -rwxr-xr-x 2 root root 9630001 10月 31 16:48 /usr/local/bin/python3.6
    lrwxrwxrwx 1 root root      17 10月 31 16:48 /usr/local/bin/python3.6-config -> python3.6m-config
    -rwxr-xr-x 2 root root 9630001 10月 31 16:48 /usr/local/bin/python3.6m
    -rwxr-xr-x 1 root root    3066 10月 31 16:48 /usr/local/bin/python3.6m-config
    lrwxrwxrwx 1 root root      16 10月 31 16:48 /usr/local/bin/python3-config -> python3.6-config
    #修改默认的python,删除旧的python的软连接,创建新的python2和python3的软连接
    [root@test Python-3.6.2]# cd /usr/bin/
    [root@test bin]# rm -f python2
    [root@test bin]# mv python python2.7.ori
    [root@test bin]# ln -s python2.7 python2
    [root@test bin]# ln -s /usr/local/bin/python3 /usr/bin/python
    #检查修改后的python版本
    [root@test bin]# python -V
    Python 3.6.2
    [root@test bin]# python2 -V
    Python 2.6.6

    # 可以看到,默认打开的python版本已经是3.6.2,至此python的版本已经升级成功

    3.后续的软件问题处理

     # python的默认版本修改为3.x之后,系统对于yum的调用会出问题,所以需要修改下yum的相关配置,另外就是,CentOS7.*还有另外一个文件需要修

    [root@test bin]# vim /usr/bin/yum
    #!/usr/bin/python2  //插入。这样,修改后的yum依然可以调用python2.7的python,在使用yum安装软件时就不会报错了
    #Centos7的修改
    [root@centos7 ~]# vim /usr/libexec/urlgrabber-ext-down
    #!/usr/bin/python2
  • 相关阅读:
    堆重启_uaf_hacknote
    记一次Spring表达式注入
    绕过waf的另类木马文件攻击方法
    西湖论剑 Flagshop 分析复现
    【测开基础之计算机网络】二: 物理层_网络_TesterAllen的博客CSDN博客
    测试面试 | 某 BAT 大厂测试开发面试真题与重点解析
    谁懂这篇文,玩游戏还会卡顿?
    移动自动化测试入门,你必须了解的背景知识和工具特性
    Python 自动化测试(三): pytest 参数化测试用例构建
    接口自动化测试分层设计与实践总结
  • 原文地址:https://www.cnblogs.com/dengcongcong/p/10932629.html
Copyright © 2011-2022 走看看