运行#Python与#python -V,看到版本是2.4.3,非常老了,并且之前写的都是跑在python3.X上面的,3.X和2.X有非常多不同,
有兴趣的朋友能够參考下这篇文章: 
http://www.jb51.net/article/34011.htm

更新python千万不要把老版本号的删除!新老版本号是能够共存的,非常多主要的命令、
软件包都要依赖预装的老版本号python的,比方yum。

一、升级到2.7.3
1. 升级安装
首先下载源tar包
可利用linux自带下载工具wget下载,例如以下所看到的:
# wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.gz

下载完毕后到下载文件夹下,解压
# tar -zxvf Python-2.7.3.tar.gz

进入解压缩后的目录
cd Python-2.7.3

在编译前先在/usr/local建一个目录python2.7.3(作为python的安装路径,以免覆盖老的版本号)
# mkdir /usr/local/python2.7.3

在解压缩后的文件夹下编译安装
# ./configure --prefix=/usr/local/python2.7.3
# make
# make install

此时没有覆盖老版本号,再将原来/usr/bin/python链接改为别的名字
# mv /usr/bin/python /usr/bin/python_old

再建立新版本号python的链接
# ln -s /usr/local/python2.7.3/bin/python2.7 /usr/bin/python

这个时候输入
# python

就会显示出python的新版本号信息
view sourceprint?
Python 2.7.3 (default, Sep 29 2013, 11:05:02)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

2.执行程序时出现错误:
File "~/PythonInstall/lib/python2.7/multiprocessing/process.py", line 129, in start
    from .forking import Popen
  File "~/PythonInstall/lib/python2.7/multiprocessing/forking.py", line 58, in <module>
    from pickle import Pickler
  File "~/PythonInstall/lib/python2.7/pickle.py", line 1266, in <module>
    import binascii as _binascii
ImportError: No module named binascii
是由于升级python版本号不正常导致的。
 
回到源文件文件夹:
# cd .../Python-2.7.3
[Python-2.7.3]# make -s
building dbm using gdbm
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c: In function '_pysqlite_set_result':
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c:552: error: 'sqlite3_int64' undeclared

(first use in this function)
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c:552: error: (Each undeclared identifier is

reported only once
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c:552: error: for each function it appears in.)
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c:552: error: expected ')' before

'PyInt_AsLong'
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c: In function '_pysqlite_build_py_params':
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c:583: error: 'sqlite3_int64' undeclared 
(first use in this function)
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c:583: error: expected ';' before 'val_int'
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c:596: error: 'val_int' undeclared (first use  in
this function)
/usr/bin/ld: /usr/local/lib/libz.a(adler32.o): relocation R_X86_64_32 against `a local symbol' can not be used when

making a shared object; recompile with -fPIC
/usr/local/lib/libz.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
/usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 against `a local symbol' can not be used when

making a shared object; recompile with -fPIC
/usr/local/lib/libz.a: could not read symbols: Bad value
collect2: ld returned 1 exit status

Python build finished, but the necessary bits to build these modules were not found:
_tkinter           bsddb185           dl              
imageop            sunaudiodev                        
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Failed to build these modules:
_sqlite3           binascii           zlib 

升级安装zlib
# wget http://sourceforge.net/projects/libpng/files/zlib/1.2.8/zlib-1.2.8.tar.gz
# tar -zxvf zlib-1.2.8.tar.gz 
# cd zlib-1.2.8
# ./configure 
# make install

# cd ../Python-2.7.3
# make -s
building dbm using gdbm
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c: In function '_pysqlite_set_result':
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c:552: error: 'sqlite3_int64' undeclared

(first use in this function)
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c:552: error: (Each undeclared identifier is reported
only once
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c:552: error: for each function it appears in.)
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c:552: error: expected ')' before

'PyInt_AsLong'
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c: In function '_pysqlite_build_py_params':
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c:583: error: 'sqlite3_int64' undeclared

(first use in this function)
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c:583: error: expected ';' before 'val_int'
/opt/PJT_python/python-2.7.3/Python-2.7.3/Modules/_sqlite/connection.c:596: error: 'val_int' undeclared (first use in
this function)

Python build finished, but the necessary bits to build these modules were not found:
_tkinter           bsddb185           dl              
imageop            sunaudiodev                        
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Failed to build these modules:
_sqlite3

升级安装sqlite3
# cd ..
# wget http://www.sqlite.org/2014/sqlite-autoconf-3080500.tar.gz
# tar -zxvf sqlite-autoconf-3080500.tar.gz
# cd sqlite-autoconf-3080500
# ./configure
# make
# make install

# cd ..
# cd python-2.7.3
# make -s
building dbm using gdbm

Python build finished, but the necessary bits to build these modules were not found:
_tkinter           bsddb185           dl              
imageop            sunaudiodev                        
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

# make clean
# make all
# make install

到此,程序就能正常执行了;

二、升级到3.3.0
更新python: 
第1步:更新gcc,
由于gcc版本号太老会导致新版本号python包编译不成功 代码例如以下:
  #yum -y install gcc

系统会自己主动下载并安装或更新,等它自己结束

第2步:下载Python-3.3.0软件包 
代码例如以下:
# wget --no-check-certificate http://python.org/ftp/python/3.3.0/Python-3.3.0.tar.bz2

注意:依照上述命令下载的软件包会存放在你当前的工作文件夹下,
wget命令是一个从网络上自己主动下载文件的自由工具,详细使用方法,
请參考这篇文章:http://www.jb51.net/os/RedHat/73089.html

说明:命令中的数字就是版本号号,你也能够把3.3.0换成你须要的版本号.

第3步:解压已下载的二进制包并编译安装 
代码例如以下:
#tar -jxvf Python-3.3.0.tar.bz2 
#cd Python-3.3.0 
#./configure 
#make all 
#make install 
#make clean 
#make distclean 
# /usr/local/bin/python3 –V 
编译安装完成以后,能够输入上面一行命令,查看版本号

第4步:建立软连接指向到当前系统默认python命令的bin文件夹,让系统使用新版本号python 
#mv /usr/bin/python /usr/bin/python2.4 //当前python的版本号为2.4所以是python2.4 
#ln -s /usr/local/bin/python3.3 /usr/bin/python 
输入
#python -V,
就可以查看当前默认python版本号 
默认的python成功指向3.3.0以后,yum不能正常使用,须要改动yum的配置文件

第5步:改动yum配置文件 
#vi /usr/bin/yum 
把文件头部的
#!/usr/bin/python  改成  #!/usr/bin/python2.4 //改为之前的老版本 
保存退出,yum就可以正常使用。

如若有其它命令、软件不能正常使用,仿照yum配置文件的改动方法,改动其配置文件就可以。 
至此,更新完成。

Redhat Linux下的python版本号升级的更多相关文章

  1. linux下修改python版本号

    修改python版本 1.查看已安装版本: /home/user$ whereis python 2.在其 home 目录下创建一个 alias(别名) user@ubuntu:/home/user$ ...

  2. linux下配置python环境 django创建helloworld项目

    linux下配置python环境 1.linux下安装python3 a. 准备编译环境(环境如果不对的话,可能遇到各种问题,比如wget无法下载https链接的文件) yum groupinstal ...

  3. Linux下查看Python安装了哪些脚本模块

    Linux下查看Python安装了哪些脚本模块 1.什么是rpm ? rpm 即RedHat Package Management,是RedHat的发明之一 .现在包括OpenLinux.fedora ...

  4. linux下安装python

    在Linux下安装Python的操作相当简单,按如下步骤操作即可: 命令: wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgzt ...

  5. 解决redhat linux下IP地址可以ping通,域名无法ping通问题

    解决redhat linux下IP地址可以ping通,域名无法ping通 在/etc/resolv.conf中添点东西 格式如下: nameserver xxx.xxx.xxx.xxx nameser ...

  6. Linux 下安装python软件包(pip、nose、virtualenv、distribute )

    新手刚开始学习Python,目前学习<笨方法学python>ing- 在学习习题46时需要安装几个软件包:pip.nose.virtualenv.distribute !在此记录Linux ...

  7. linux下安装python linux下一些常用的命令

    注意 ubuntukylin-14.04.2-desktop-amd64 自带python2.7.6 这个说的比较详细 http://wenku.baidu.com/link?url=gaeFcQrc ...

  8. linux下搭建python机器学习环境

    前言 在 linux 下搭建 python 机器学习环境还是比较容易的,考虑到包依赖的问题,最好建立一个虚拟环境作为机器学习工作环境,在建立的虚拟环境中,再安装各种需要的包,主要有以下6个(这是看这个 ...

  9. Python3.x:Linux下退出python命令行

    Python3.x:Linux下退出python命令行 退出命令: quit() #或者 exit() #或者 Ctrl-D

随机推荐

  1. POJ 3422 Kaka&#39;s Matrix Travels(费用流)

    POJ 3422 Kaka's Matrix Travels 题目链接 题意:一个矩阵.从左上角往右下角走k趟,每次走过数字就变成0,而且获得这个数字,要求走完之后,所获得数字之和最大 思路:有点类似 ...

  2. Oracle游标(光标)

     watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdGFuZ2xpdXFpbmc=/font/5a6L5L2T/fontsize/400/fill/I0J ...

  3. Cocos2d-x-Lua 开发一个简单的游戏(记数字步进白色块状)

    Cocos2d-x-Lua 开发一个简单的游戏(记数字步进白色块状) 本篇博客来给大家介绍怎样使用Lua这门语言来开发一个简单的小游戏-记数字踩白块. 游戏的流程是这种:在界面上生成5个数1~5字并显 ...

  4. 香蕉派路由功Openwrt、Android功耗对照測试

    路由这个东西是要长期通电使用的,所以功耗也是须要关注的.如今香蕉派路由已经有了openwrt和android两个 系统,这两个系统的功耗是否一样呢? 測试工具:QUIGG的德国产功耗測试仪一个.手机充 ...

  5. 【C语言探索之旅】 第二部分第二课:进击的指针,C语言的王牌!

    内容简介 1.课程大纲 2.第二部分第二课: 进击的指针,C语言的王牌 3.第二部分第三课预告: 数组 课程大纲 我们的课程分为四大部分,每一个部分结束后都会有练习题,并会公布答案.还会带大家用C语言 ...

  6. 文章之间的基本总结:Activity生命周期

    孔子:温故而知新.它可以作为一个教师.<论语> 同样的学习技巧.对于技术文件或书籍的经典技术,期待再次看到它完全掌握,这基本上是不可能的,所以,我们常常回来几次,然后仔细研究,为了理解作者 ...

  7. android采用videoView播放视频(包装)

    //android播放视频.用法:于androidManifest.xml添加activity, // <activity android:name=".PlayVideo" ...

  8. overflow的几个坑

    在android 4.0的原生浏览器上注意: html元素上不要加overflow: auto;的样式,否则会造成有些元素无法点击 在absolute元素上 不要加 overflow: auto; 否 ...

  9. “MEAN”技术栈开发web应用

    “MEAN”技术栈开发web应用 上一篇我们讲了如何使用angular搭建起项目的前端框架,前端抽象出一个service层来向后端发送请求,后端则返回相应的json数据.本篇我们来介绍一下,如何在no ...

  10. 如何设置eclipse在默认模式下打开文件

    如何设置eclipse在默认模式下打开文件 打开eclipse.选择例如以下:windows --> preferences --> General --> Editors --&g ...