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. 获取枚举Description的Name

    /// <summary> /// 获取枚举Description的Name /// </summary> /// <param name="enumName& ...

  2. Shell 总结

    find: –name 'filenme' * ? [] ; –iname; –regex PATTERN; –user username; –group; –uid; –gid; –nouser; ...

  3. 从零开始学ios开发(十九):Application Settings and User Defaults(上)

    在iphone和ipad中,有一个东西大家一定很熟悉,那个东西就是Settings. 这次要学习的东西说白了很简单,就是学习如何在Settings中对一个app的某些属性进行设置,反过来,在app中更 ...

  4. Qt实现指定线程执行回调

    说明 同线程时,直接调用回调(block参数没意义) 创建invoker所在的线程,需要有Qt的消息循环(比如UI线程) 直接上代码 typedef std::function<void()&g ...

  5. Week1 Team Homework #1: Study the projects done by previous student groups

      我们研究了学长的项目:百度3D地图API的调用.下面是我们对该项目的一些看法: 优点: 界面清晰 各类之间调用及其他关系容易理清. 缺点: 前段html代码过于冗杂,很多(div)块间的层次关系不 ...

  6. 音频播放、录音、视频播放、拍照、视频录制-b

    随着移动互联网的发展,如今的手机早已不是打电话.发短信那么简单了,播放音乐.视频.录音.拍照等都是很常用的功能.在iOS中对于多媒体的支持是非常强大的,无论是音视频播放.录制,还是对麦克风.摄像头的操 ...

  7. Codeforces Round #359 (Div. 2) D. Kay and Snowflake 树的重心

    题目链接: 题目 D. Kay and Snowflake time limit per test 3 seconds memory limit per test 256 megabytes inpu ...

  8. Java7 新特性 switch 可以使用String

    今天和大家分享下 在java7中可以使用String 作为switch 中的参数. 原来在java7之前,switch只能去接收一个 byte.char.short.int 类型 现在在java7中 ...

  9. TensorFlow 基本使用

    使用 TensorFlow, 你必须明白 TensorFlow: 使用图 (graph) 来表示计算任务. 在被称之为 会话 (Session) 的上下文 (context) 中执行图. 使用 ten ...

  10. HTML5 动画引擎 小记

    国内: Cocos2d-x js版本   layabox Egret Sirius2D lufylegend.js Fireball 国外: CreateJS(EaselJS.TweenJS)http ...