最近需要在linux下使用python,故需要升级一下python版本,上网查询了一下相关资料,更新了一下linux下面的python环境,记录如下:

linux下面升级 Python版本并修改yum属性信息

首先linux下查询python版本

[root@test30 chengshaoling]# python -V

Python 2.7.5

1.最新版本python下载安装

下载新版本的python

python主站相关地址:

https://www.python.org/downloads/source/

https://www.python.org/downloads/release/python-2712/

https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz

[root@test30 makePython]# wget   https://www.python.org/downloads/release/python-373/Python-3.7.3.tgz   #下载的不完整,又手动网页下载,上传到Linux系统的

解压缩 以及编译

[root@test30 makePython]# tar -xvf Python-2.7.12.tgz

[root@test30 makePython]# cd Python-2.7.12

[root@test30 Python-2.7.12]# ./configure --prefix=/usr/local/python27    #我运行了   ./configure  后又运行了./configure --prefix=/usr/local/python37

[root@test30 Python-2.7.12]# make

[root@test30 Python-2.7.12]# make install

再次查看python版本,系统展现版本未更新

[root@test30 Python-2.7.12]# python -V

Python 2.7.5

2. python多版本共存解决

下面来解决这个问题

把原来的python重命名成python_old,注意不要删除

[root@test30 Python-2.7.12]# mv /usr/bin/python /usr/bin/python_old

[root@test30 Python-2.7.12]# ln -s /usr/local/python37/bin/python3 /usr/bin/python

再查看一下版本

[root@test30 Python-2.7.12]#python -V

Python 3.7.3

成功更新python版本

3.解决yum的python版本问题

还有最后一个问题要解决,因为yum是使用的python2.7.5的版本,所以 还需要修改一下yum的python版本(利用前面重命名的python_old文件夹的内容)

[root@test30 Python-2.7.12]# yum

There was a problem importing one of the Python modules

required to run yum. The error leading to this problem was:

No module named yum

Please install a package which provides this module, or

verify that the module is installed correctly.

It's possible that the above module doesn't match the

current version of Python, which is:

2.7.12 (default, Nov 29 2016, 11:07:49)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]

If you cannot solve this problem yourself, please go to

the yum faq at:

http://yum.baseurl.org/wiki/Faq

修改yum文件中配置的python程序位置:

[root@test30 Python-2.7.12]# cd /usr/bin/

[root@test30 bin]# vi yum

#!/usr/bin/python_old    #修改此处为原始python程序的位置  #后边不能写注释,会出问题  不知道为啥

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:

%s

Please install a package which provides this module, or

verify that the module is installed correctly.

It's possible that the above module doesn't match the

current version of Python, which is:

%s

If you cannot solve this problem yourself, please go to

the yum faq at:

http://yum.baseurl.org/wiki/Faq

""" % (sys.exc_value, sys.version)

sys.exit(1)

sys.path.insert(0, '/usr/share/yum-cli')

try:

import yummain

yummain.user_main(sys.argv[1:], exit_code=True)

except KeyboardInterrupt, e:

print >> sys.stderr, "\n\nExiting on user cancel."

sys.exit(1)

~

~

~

~

~

~

~

~

~

~

~

"yum" 32L, 805C

验证 yum 是否重新可以使用

[root@test30 bin]# yum

已加载插件:fastestmirror

你需要给出命令

Usage: yum [options] COMMAND

List of Commands:

check          Check for problems in the rpmdb

check-update   检查是否有软件包更新

clean          删除缓存的数据

deplist        列出软件包的依赖关系

distribution-synchronization Synchronize installed packages to the latest available versions

downgrade      downgrade a package

erase          从系统中移除一个或多个软件包

groupinfo      显示组的详细信息

groupinstall   向系统中安装一组软件包

grouplist      列出可安装的组

groupremove    从系统中移除一组软件包

help           显示用法信息

history        Display, or use, the transaction history

info           显示关于软件包或组的详细信息

install        向系统中安装一个或多个软件包

list           列出一个或一组软件包

load-transaction load a saved transaction from filename

makecache      创建元数据缓存

provides       查找提供指定内容的软件包

reinstall      覆盖安装一个包

repolist       显示已配置的仓库

resolvedep     判断哪个包提供了指定的依赖

search         在软件包详细信息中搜索指定字符串

shell          运行交互式的 yum 外壳

update         更新系统中的一个或多个软件包

upgrade        更新软件包同时考虑软件包取代关系

version        Display a version for the machine and/or available repos.

Options:

-h, --help            show this help message and exit

-t, --tolerant        容忍错误

-C, --cacheonly       run entirely from system cache, don't update cache

-c [config file], --config=[config file]

配置文件路径

-R [minutes], --randomwait=[minutes]

命令最长等待时间

-d [debug level], --debuglevel=[debug level]

调试输出级别

--showduplicates      在 list/search 命令下,显示仓库里重复的条目。

-e [error level], --errorlevel=[error level]

错误输出级别

--rpmverbosity=[debug level name]

debugging output level for rpm

-q, --quiet           安静的操作

-v, --verbose         verbose operation

-y, --assumeyes       回答所有的问题为是

--assumeno            answer no for all questions

--version             显示 Yum 版本信息并退出

--installroot=[path]  设置目标根目录

--enablerepo=[repo]   启用一个或多个仓库(支持通配符)

--disablerepo=[repo]  禁用一个或多个仓库(支持通配符)

-x [package], --exclude=[package]

用全名或通配符排除软件包

--disableexcludes=[repo]

禁止从主配置,从仓库或者从任何位置排除

--obsoletes           升级时考虑软件包取代关系

--noplugins           禁用 Yum 插件

--nogpgcheck          禁用 gpg 签名检测

--disableplugin=[plugin]

禁用指定名称的插件

--enableplugin=[plugin]

enable plugins by name

--skip-broken         跳过有依赖问题的软件包

--color=COLOR         配置是否使用颜色

--releasever=RELEASEVER

set value of $releasever in yum config and repo files

--downloadonly        don't update, just download

--downloaddir=DLDIR   specifies an alternate directory to store packages

--setopt=SETOPTS      set arbitrary config and repo options

插件选项:

至此,python升级完成

参考:http://blog.sina.com.cn/s/blog_53f023270102vdvo.html

参考:https://blog.csdn.net/jiangshan35/article/details/69568271

参考:https://www.cnblogs.com/eleganthua/p/9406968.html

总结:python 升级;默认调用改为升级后的Python;但是,yum不能配套使用升级后的Python,yum 改为默认路径为老的Python包路径;

转载于:https://www.cnblogs.com/Formulate0303/p/11121562.html

linux下面升级 Python版本并修改yum属性信息相关推荐

  1. linux中更新python_linux下面升级 Python版本并修改yum属性信息

    最近需要在linux下使用python,故需要升级一下python版本,上网查询了一下相关资料,更新了一下linux下面的python环境,记录如下: linux下面升级 Python版本并修改yum ...

  2. linux下怎么升级python版本,Linux下升级python版本

    转载自:http://lovebeyond.iteye.com/blog/1770476 CentOS下的Python版本一般都比较低,很多应用都需要升级python来完成.我装的centOS的默认的 ...

  3. linux下python版本升级,linux下升级python版本

    linux下升级python版本 下载python最新版本2.7.13并编译安装 wget https://www.python.org/ftp/python/2.7.12/Python-2.7.13 ...

  4. linux下python版本升级,Linux下升级python版本(示例代码)

    转载自:http://lovebeyond.iteye.com/blog/1770476 CentOS下的Python版本一般都比较低,很多应用都需要升级python来完成.我装的centOS的默认的 ...

  5. python:linux中升级python版本

    https://www.cnblogs.com/gne-hwz/p/8586430.html 转载于:https://www.cnblogs.com/gcgc/p/11446403.html

  6. linux 升级python 3.5,Linux下升级Python到3.5.2版本

    本文主要介绍在Linux(CentOS)下将Python的版本升级为3.5.2的方法 众所周知,在2020年python官方将不再支持2.7版本的python,所以使用3.x版本的python是必要的 ...

  7. linux python版本_linux下更新Python版本并修改默认版本

    linux下更新Python版本并修改默认版本,有需要的朋友可以参考下. 很多情况下拿到的服务器python版本很低,需要自己动手更改默认python版本 1.从官网下载python安装包(这个版本可 ...

  8. python更新到什么版本_Linux更新Python版本及修改python默认版本的方法

    linux下更新Python版本并修改默认版本,有需要的朋友可以参考下. 很多情况下拿到的服务器python版本很低,需要自己动手更改默认python版本 1.从官网下载python安装包(这个版本可 ...

  9. linux下升级g 版本,linux下升级gcc版本(gcc-7)

    ubuntu16.04的自带gcc版本为gcc-5,因为安装pl-slam的需要升级到gcc-7,可以通过以下命令查看你的gcc版本 gcc --version 通过apt工具对gcc进行升级 sud ...

最新文章

  1. CentOS7 升级 Git 版本
  2. CSS 中功能相似伪类间的区别
  3. 11.python并发入门(part4 死锁与递归锁)
  4. 初始化Dictionarystring, object赋值
  5. LeetCode 算法 856. 括号的分数
  6. 备受期待!机器学习“蜥蜴书”最新版来了!豆瓣评分9.9!
  7. Flex整合Spring
  8. google annotation笔记
  9. 《html5 从入门到精通》读书笔记(三)
  10. 实战Javascript:结合电商主界面实现轮播图和倒计时秒杀
  11. 甲骨文超 IBM 成全球第二大软件公司
  12. C0型单元刚度矩阵的性质
  13. 声网合伙人王骅:聊聊企业拥抱全球化 关键是什么?
  14. 忘记网站服务器密码怎么办,忘记远程服务器的密码怎么办
  15. 金山卫士开源软件之旅(九) KUI高级界面(列表控件、树控件例子、超文本、网页控件)
  16. 【《游戏引擎架构》提炼总结】(一)游戏是什么,游戏引擎架构导论
  17. conda安装python虚拟环境+配置channels
  18. 众创美业微信引流系统使用说明
  19. windows下的python安装scrapy
  20. 计算机专业毕业英文论文一万字,计算机专业毕业论文外文翻译2篇共15页.DOC

热门文章

  1. Live555研究之二Sleep实现
  2. Android系统介绍
  3. 对于SAP的月结相关流程介绍
  4. 深入浅出之正则表达式(一)
  5. ASP.NET中全局变量
  6. 【每天一道算法题】Numeric Keypad
  7. Windows下将nginx安装为服务运行
  8. (转) iPhone UI 开发的几点建议
  9. 关于 paddingFactor 及 COLLMOD 的设置值
  10. android 访问https服务器