CentOS 6.X怎么更新centos6安装python2.77.x版本

RedHat升级Python到2.7.6_Linux教程_Linux公社-Linux系统门户网站
你好,游客
RedHat升级Python到2.7.6
来源:Linux社区&
作者:benbenxiong
从今天开始学习Python!看了一下虚拟机中的python,发现还是原生的2.4.3,所以决定升级一下
[root@linuxidc ~]# python&Python 2.4.3 (#1, May& 5 :10)[GCC 4.1.2
( 4.1.2-50)] on linux2Type "help", "copyright", "credits" or "license" for more information.&&&[root@linuxidc ~]#
1.下载z最新版本的python
[root@linuxidc ~]# wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tgz
2.解压及编译
[root@linuxidc ~]# tar xvf Python-2.7.2.tar.bz2[root@linuxidc Python-2.7.6]# ./configure --prefix=/usr/local/python27[root@linuxidc Python-2.7.6]# make[root@linuxidc Python-2.7.6]# make install
[root@linuxidc Python-2.7.6]# ls /usr/local/python27/ -altotal 28drwxr-xr-x& 6 root root 4096 Mar 21 01:01 .drwxr-xr-x 13 root root 4096 Mar 21 01:01 ..drwxr-xr-x& 2 root root 4096 Mar 21 01:01 bindrwxr-xr-x& 3 root root 4096 Mar 21 01:01 includedrwxr-xr-x& 4 root root 4096 Mar 21 01:01 libdrwxr-xr-x& 3 root root 4096 Mar 21 01:01 share
3.覆盖原有的python链接
[root@linuxidc Python-2.7.6]# mv /usr/bin/python /usr/bin/python_old[root@linuxidc Python-2.7.6]# ln -s /usr/local/python27/bin/python /usr/bin/[root@linuxidc Python-2.7.6]# pythonPython 2.7.6 (default, Mar 21 :09) [GCC 4.1.2
(Red Hat 4.1.2-44)] on linux2Type "help", "copyright", "credits" or "license" for more information.&&&
此时已经可以正常使用python2.7了,但是因为yum是使用的2.4的版本来用的,现在输入一下yum就会报错
[root@linuxidc Python-2.7.6]# yumThere was a problem importing one of the Python modulesrequired to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, orverify that the module is installed correctly.
It's possible that the above module doesn't match thecurrent version of Python, which is:2.7.6 (default, Mar 21 :09) [GCC 4.1.2
(Red Hat 4.1.2-44)]
If you cannot solve this problem yourself, please go to the yum faq at:& http://wiki.linux.duke.edu/YumFaq
[root@linuxidc Python-2.7.6]# vim /usr/bin/yum
#!/usr/bin/python&
#修改此处为2.4的位置
[root@linuxidc Python-2.7.6]# vim /usr/bin/yum
#!/usr/bin/python2.4
yum 可以使用了!
[root@linuxidc Python-2.7.6]# yumLoaded plugins: rhnplugin, securityYou need to give some commandusage: yum [options] COMMAND
List of Commands:
check-update&
Check for available package updatesclean& & & & & Remove cached datadeplist& & & & List a package's dependencieserase& & & & & Remove a package or packages from your systemgroupinfo& & & Display details about a package groupgroupinstall&
Install the packages in a group on your systemgrouplist& & & List available package groupsgroupremove& & Remove the packages in a group from your systemhelp& & & & &
Display a helpful usage messageinfo& & & & &
Display details about a package or group of packagesinfo-security& Returns security data for the packages listed, that affects your systeminstall& & & & Install a package or packages on your systemlist& & & & &
List a package or groups of packageslist-security& Returns security data for the packages listed, that affects your systemlocalinstall&
Install a local RPMmakecache& & & Generate the metadata cacheprovides& & &
Find what package provides the given valuereinstall& & & reinstall a packagerepolist& & &
Display the configured software repositoriesresolvedep& &
Determine which package provides the given dependencysearch& & & &
Search package details for the given stringshell& & & & & Run an interactive yum shellupdate& & & &
Update a package or packages on your systemupdate-minimal Works like update, but goes to the 'newest' package match which fixes a problem that affects your systemupgrade& & & & Update packages taking obsoletes into account
options:& -h, --help& & & & & & show this help message and exit& -t, --tolerant& & & & be tolerant of errors& -C& & & & & & & & & & run entirely from cache, don't update cache& -c& [config file]& &
config file location& -R& [minutes]& & & &
maximum command wait time& -d& [debug level]& &
debugging output level& --showduplicates& & & show duplicates, in repos, in list/search commands& -e& [error level]& &
error output level& -q, --quiet& & & & &
quiet operation& -v, --verbose& & & &
verbose operation& -y& & & & & & & & & & answer yes for all questions& --version& & & & & &
show Yum version and exit& --installroot=[path]& set install root& --enablerepo=[repo]&
enable one or more repositories (wildcards allowed)& --disablerepo=[repo]& disable one or more repositories (wildcards allowed)& -x [package], --exclude=[package]& & & & & & & & & & & & exclude package(s) by name or glob& --disableexcludes=[repo]& & & & & & & & & & & & disable exclude from main, for a repo or for& & & & & & & & & & & & everything& --obsoletes& & & & &
enable obsoletes processing during updates& --noplugins& & & & &
disable Yum plugins& --nogpgcheck& & & & & disable gpg signature checking& --disableplugin=[plugin]& & & & & & & & & & & & disable plugins by name& --enableplugin=[plugin]& & & & & & & & & & & & enable plugins by name& --skip-broken& & & &
skip packages with depsolving problems& --security& & & & & & Include security relevant packages& --cve=CVE& & & & & &
Include packages needed to fix the given CVE& --bz=BZ& & & & & & &
Include packages needed to fix the given BZ& --advisory=ADVISORY&
Include packages needed to fix the given advisory[root@linuxidc Python-2.7.6]#
Python 的详细介绍:Python 的下载地址:
推荐阅读:
《Python开发技术详解》.( 周伟,宗杰).[高清PDF扫描版+随书视频+代码]
Python脚本获取Linux系统信息
更多RedHat相关信息见 专题页面
相关资讯 & & &
& (11/29/:56)
& (06/27/:02)
& (02月09日)
& (07/07/:17)
& (05/12/:09)
   同意评论声明
   发表
尊重网上道德,遵守中华人民共和国的各项有关法律法规
承担一切因您的行为而直接或间接导致的民事或刑事法律责任
本站管理人员有权保留或删除其管辖留言中的任意内容
本站有权在网站内转载或引用您的评论
参与本评论即表明您已经阅读并接受上述条款centos 6.8 安装python2.7.x环境 - 博客频道 - CSDN.NET
GO_LOHAS的博客
分类:python
简单记录下,centos6.x 上安装 python2.7.x 过程:
1、系统版本:CentOS-6.8-x86_64-minimal.iso
1&安装前准备:
保证系统能上网然后用yum命令安装以下软件:make、zlib-devel、bzip2-devel、openssl-devel、ncurses-devel、sqlite-devel、gcc&
命令安装举例:
安装make: yum install make &&
python官网下载python2.7.x的源码包,然后解压 tar -zvxf &Python-2.7.11.tgz
2&安装python
进入解压包 cd python-2.7.11,我要把python安装到目录 /usr/local 下,所以
./configure --prefix=/usr/local
make&&make altinstall
3&安装完成后,设置python的环境:
进入/etc/profile.d/ 目录,创建 python.sh 文件并添加如下内容:
创建文件命令 &vim python.sh (如果没有vim命令,可以用vi)
export PATH=”/usr/local/bin:$PATH”&
添加完成之后保存文件,重启系统 init 6
4&安装setuptoool
wget --no-check-certificate(如果没有wget命令,可以用yum
install wget 安装)
python ez_setup.py –insecure
wget--no-check-certificate
tar -zxvf 1.5.5.tar.gz
python setup.py install
pip自升级:pip install -U pip
到这里安装就差不多了。如果想安装插件的话,直接用pip install 就可以了。
排名:千里之外记录在centos6.4和6.6下把python2.6.X升级到2.7.9的心路历程 - 博客频道 - CSDN.NET
云杉的博客
我的愿望是
分类:环境搭建
感谢:/?p=9
先声明下,本以为在centos下升级python很easy,,没想到是个大坑。有的能装好,但是不能用。各种缺失吧,非常蛋疼。
下面整理下思路,从python2.6.X升级到python2.7.9,同时安装了setuptools以及pip
1、从python2.6.X升级python到2.7.9
& &&CentOS 6.X默认的Python版本都是2.6 ,需要升级到2.7以及安装pip方法如下:
yum install bzip2 bzip2-devel -y
yum install zlib zlib-devel -y
yum install openssl openssl-devel -y
下载python2.7源码,编译安装:wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
tar zxvf Python-2.7.9.tgz
cd Python-2.7.9
./configure
make install然后需要配置一下# 建立软链接,默认指向Python2.7
mv /usr/bin/python /usr/bin/python2.6_temp
ln -s /usr/local/bin/python2.7 /usr/bin/python
# Python 2.7.9
# yum不兼容Python2.7,需要指定为原版本
vi /usr/bin/yum
# 将&!/usr/bin/python&改为&!/usr/bin/python2.6&
# 环境变量
vi /etc/profile
# 添加如下内容:
PY_HOME=/usr/local/bin/python2.7
export PATH=$PY_HOME/bin:$PATH
source /etc/profile
# 当前终端生效,reboot后才会完全生效
echo $PATH如果你升级python失败,用这个方法,这个方法可以直接搞定!
解决交互式乱码问题
(参考 http://blog.csdn.net/clevercode/article/details/)
2)解决方案。这个问题主要是由于缺少readline Module问题导致的。而CentOS默认只有readline模块而没有readline-devel开发模块。所以只要安装下即可。# yum -y install readline-devel
重新编译安装python# cd
#回到解压目录# ./configure # make &
#编译# make install
2、安装setuptools
wget https://pypi.python.org/packages/6b/dd/a7de8caeeffab76bacfc12e0ae6932245abbce6/setuptools-28.3.0.tar.gz#md5=aab0e2721a
tar zxvf setuptools-28.3.0.tar.gz&
cd setuptools-28.3.0
python setup.py install
3、安装pip
wget https://pypi.python.org/packages/e7/a8/add8d1a54c0b14aeff0acb03c6ecd5/pip-8.1.2.tar.gz#md5=aba
tar pip-8.1.2.tar.gz&
tar zxvf &pip-8.1.2.tar.gz&
cd pip-8.1.2&
python setup.py install
排名:千里之外
(4)(9)(0)(9)(1)(2)(2)(4)(5)(2)(13)(5)(0)(0)(2)(6)(1)(1)(3)(1)(5)(6)(4)(0)}

我要回帖

更多关于 centos更新python版本 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信