CentOS7 升级python同时解决yum损坏问题
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损坏问题的更多相关文章
- 转载: Centos7 升级python3,解决升级后不兼容问题
Centos7配置更新国内yum源 http://blog.csdn.net/qingguiyu/article/details/50721956 Centos7 升级python3,解决升级后不兼容 ...
- Linux实战(4):Centos7升级python
记一笔升级python后产生的问题,并给予解决方案.莫慌看下文: 升级python3 我是直接 yum安装的,当然安装方法有很多,不喜欢此安装方式的可选用其他方式,我再此就不一一解释了.安装方式可不同 ...
- Centos7升级python版本
升级Python 我的安装目录是/home/python 下载 ` cd /home/python wget https://www.python.org/ftp/python/3.5.0/Pytho ...
- centos7升级Python版本后,yum不能正常使用
python升级方法,使用源码编译安装即可,prefix=/usr/local/bin/python3 执行yum list,提示/usr/bin/yum 报错 我是直接在Python2.7的基础上又 ...
- CentOS6.5 升级 Python 2.7 版本
转载请注明出处http://write.blog.csdn.net/mdeditor 目录 目录 前言 安装Python-279 解决YUM与Python279的兼容问题 前言 CentOS 6.5中 ...
- linux centos系统下升级python版本
本文参考资料:https://www.cnblogs.com/leon-zyl/p/8422699.html,https://blog.csdn.net/tpc1990519/article/deta ...
- CentOS 6.5升级Python后yum不可用的解决方案
因开发需要,今天把CentOS 6.5自带的Python2.6.6升级到了Python2.7.3.按照如下步骤进行升级 1.查看当前系统python的版本 python -V 2.下载2.7.3版本的 ...
- Linux升级Python提示Tkinter模块找不到解决
一.安装tkinter 在Linux中python默认是不安装Tkinter模块, [root@li250- ~]# python Python (r266:, Feb , ::) [GCC (Red ...
- CentOS 7升级Python到3.5后yum出错
CentOS 7升级Python到3.5后,我跟以前CentOS 6一样,在/usr/bin/python创建了一个指向Python 3的软连接,然后将/usr/bin/yum的顶部的: !/usr/ ...
随机推荐
- 使用CSS画一个三角形
<div style="width:0px;height:0px;border-width:40px;border-style:solid;border-color:transpare ...
- Python标准库之urllib,urllib2自定义Opener
urllib2.urlopen()函数不支持验证.cookie或者其它HTTP高级功能.要支持这些功能,必须使用build_opener()函数创建自定义Opener对象. 1. build_open ...
- Django Form的学习
django.forms 是Django处理form的库 本质上可以直接通过对HttpRequest达到同样的效果,但是django.from带来更便捷的处理方式.功能有几点 通过form类 ...
- 1097. Deduplication on a Linked List (25)
Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated ...
- linux 目录
创建和删除 int mkdir(const char *pathname, mode_t mode); int rmdir(const char *pathname); 另外remove也可以删除文件 ...
- WPF中的Style
一.Style基础知识 构成Style最重要的两种元素是Setter和Trigger Setter类帮助我们设置控件的静态外观风格 Trigger类帮助我们设置控件的行为风格 Setter类的Prop ...
- 9、XAML名称空间详解
XAML命名空间 <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ...
- Rac & DG
Rac环境: RAC版本异同:[10R2,11R1(和10类似)],11R2,12c: 目录: 10.2的ASM需要单独的目录(oracle home):rdbms home,asm home, cr ...
- python学习小结2:if和while控制语句
if语句 if语句中,代码块是按缩进的空格数量来判断的,也就是说空格数量一致的相邻行会被当作一个代码块,当if的条件成立的时候它就会得到执行. x = 100 if x > 50: print ...
- LintCode-Implement Iterator of Binary Search Tree
Design an iterator over a binary search tree with the following properties: Elements are visited in ...