CentOS7中的python版本为python2.7.5,升级到最新版的python时需要注意两个问题

  • 新版的python安装好后要修改python的系统默认指向问题
  • 升级到最新版python后yum报错的问题

下面对新版的安装步骤进行说明。

 一、下载并安装最新版python

  1.下载并解压

# wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
# tar -zxf Python-3.5..tgz

  2.安装Python

# cd Python-3.5./# ./configure 
# make
# make install 查看是否安装成功 # /usr/local/bin/python3.5
Python 3.5.2 (default, Jul 24 2016, 14:46:50)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

  3.修改python的系统默认指向,修改软链接

  正常情况下,新版本的python安装后系统等其他应用指向的python环境依然是老版本的python,

  如果删除老版本后再装新版本会面临很多难以定位的麻烦,所以通常的做法是:

  老版本依然保留,新版本并行存在。操作方法如下

()修改系统默认的python修改为2..5版本

# mv /usr/bin/python /usr/bin/python2.7.5

()创建软连接使python指向新版本

# ln -s /usr/local/bin/python3. /usr/bin/python

()检测是否更新成功

[root@localhost ~]# python
Python 3.5. (default, Jul , ::)
[GCC 4.8. (Red Hat 4.8.-)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

 二、yum报错问题解决

  1.终端下输入yum后报错信息如下

[root@localhost ~]# yum
File "/usr/bin/yum", line
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax

  2.vim /usr/bin/yum

   修改python头部python为python2.7.5

#!/usr/bin/python2.7.5
import sys
try:
import yum
except ImportError:
print >> sys.stderr, """\
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

  3.再次查看yum是否可用

[root@localhost ~]# yum
Loaded plugins: fastestmirror, langpacks
You need to give some command
Usage: yum [options] COMMAND List of Commands: check Check for problems in the rpmdb
check-update Check for available package updates
clean Remove cached data
deplist List a package's dependencies

... ...

CentOS7 升级python同时解决yum损坏问题的更多相关文章

  1. 转载: Centos7 升级python3,解决升级后不兼容问题

    Centos7配置更新国内yum源 http://blog.csdn.net/qingguiyu/article/details/50721956 Centos7 升级python3,解决升级后不兼容 ...

  2. Linux实战(4):Centos7升级python

    记一笔升级python后产生的问题,并给予解决方案.莫慌看下文: 升级python3 我是直接 yum安装的,当然安装方法有很多,不喜欢此安装方式的可选用其他方式,我再此就不一一解释了.安装方式可不同 ...

  3. Centos7升级python版本

    升级Python 我的安装目录是/home/python 下载 ` cd /home/python wget https://www.python.org/ftp/python/3.5.0/Pytho ...

  4. centos7升级Python版本后,yum不能正常使用

    python升级方法,使用源码编译安装即可,prefix=/usr/local/bin/python3 执行yum list,提示/usr/bin/yum 报错 我是直接在Python2.7的基础上又 ...

  5. CentOS6.5 升级 Python 2.7 版本

    转载请注明出处http://write.blog.csdn.net/mdeditor 目录 目录 前言 安装Python-279 解决YUM与Python279的兼容问题 前言 CentOS 6.5中 ...

  6. linux centos系统下升级python版本

    本文参考资料:https://www.cnblogs.com/leon-zyl/p/8422699.html,https://blog.csdn.net/tpc1990519/article/deta ...

  7. CentOS 6.5升级Python后yum不可用的解决方案

    因开发需要,今天把CentOS 6.5自带的Python2.6.6升级到了Python2.7.3.按照如下步骤进行升级 1.查看当前系统python的版本 python -V 2.下载2.7.3版本的 ...

  8. Linux升级Python提示Tkinter模块找不到解决

    一.安装tkinter 在Linux中python默认是不安装Tkinter模块, [root@li250- ~]# python Python (r266:, Feb , ::) [GCC (Red ...

  9. CentOS 7升级Python到3.5后yum出错

    CentOS 7升级Python到3.5后,我跟以前CentOS 6一样,在/usr/bin/python创建了一个指向Python 3的软连接,然后将/usr/bin/yum的顶部的: !/usr/ ...

随机推荐

  1. sql拆分查询

    有这样一个需求: 临时表sql: create table #AA ( ID int, Name nvarchar(20) ) insert #AA select 1,'苏州/上海/温州' union ...

  2. Java从入门到精通——数据库篇Oracle 11g服务详解

    装上Oracle之后大家都会感觉到我们的电脑慢了下来,如何提高计算机的速度呢?我们应该打开必要的服务,关闭没有用的服务.下面是Oracle服务的详解: Oracle ORCL VSS Writer S ...

  3. python之参数

    1. 参数传递有2种方式: 按位置传递, 按关键字传递. 2. 形参可以定义默认值, 可以用*收集元组, 可以用**收集字典. 其中, (1)指定默认值的形参可不接收实参. (2)指定*的形参用元组收 ...

  4. docker 感性体验

    Docker 1.0正式发布!1.0 版本包含很多新特性,这也是 Docker 的首个产品级的版本.从今天开始,你将会一直听到一个新的概念 —— Docker as a platform ,其组件包括 ...

  5. C# Socket连接请求超时机制

    作者:RazanPaul 译者:Todd Wei 原文:http://www.codeproject.com/KB/IP/TimeOutSocket.aspx 介绍 您可能注意到了,.Net的Syst ...

  6. 结构体,公用体,枚举类型的sizeof

    1)枚举类enum型空间计算 enum只是定义了一个常量集合,里面没有“元素”,而枚举类型是当做int来存储的,所以枚举类型的sizeof值都为4 enum color(red,pink,white, ...

  7. google api , using a refresh token to get the access token

    router.get('/refresh',function(req,res){ oauth2Client.credentials = { refresh_token: '1/RqVyL7yLBxws ...

  8. Fragment inner class should be static

    package com.example.fragmenttest; import android.annotation.SuppressLint; import android.app.Activit ...

  9. Careercup - Google面试题 - 5205167846719488

    2014-05-03 23:35 题目链接 原题: For a given node in binary search tree find a next largest number in searc ...

  10. ios开发之多线程

    多线程的主要是用来执行一些耗时操作,例如网络图片.视频.歌曲.书籍等资源下载,游戏中的音乐播放等,充分发挥多核处理器的优势,并发(同时执行)任务让系统运行的更快.更流畅. 介绍下比较常用的多线程技术, ...