安装python2.7.8
[root@kcw ~]# rpm -q python python-2.6.6-52.el6.x86_64 CnetOS6.5当前安装的python版本 解压 [root@kcw ~]# tar xf Python-2.7.8.tar.xz [root@kcw ~]# cd Python-2.7.8 [root@kcw Python-2.7.8]# ls config.guess Demo install-sh Makefile.pre.in Parser Python Tools config.sub Doc Lib Misc PC README configure Grammar LICENSE Modules PCbuild RISCOS configure.ac Include Mac Objects pyconfig.h.in setup.py [root@kcw Python-2.7.8]# ./configure --prefix=/usr/local/python27 [root@kcw Python-2.7.8]# make && make install [root@kcw Python-2.7.8]# /usr/local/python27/bin/python2.7 测试能否使用 Python 2.7.8 (default, Oct 26 2014, 20:29:45) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print "Hello py" Hello py
安装iPython,Ipython是python的一个模块必须使用python来安装 其实Ipython可用直接使用tab补齐
[root@kcw ipython-2.3.0]# tar xf ipython-2.3.0.tar.gz [root@kcw ipython-2.3.0]# cd ipython-2.3.0 [root@kcw ipython-2.3.0]# /usr/local/python27/bin/python2.7 setup.py build [root@kcw ipython-2.3.0]# /usr/local/python27/bin/python2.7 setup.py install 测试iPython是否可用 [root@kcw ipython-2.3.0]# /usr/local/python27/bin/ipython WARNING: IPython History requires SQLite, your history will not be saved Python 2.7.8 (default, Oct 26 2014, 20:29:45) Type "copyright", "credits" or "license" for more information. IPython 2.3.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: print "Hello py" Hello py In [2]: import sys In [3]: sys.<tab><tab>
为了方便使用可用使用一个软链接
[root@kcw ipython-2.3.0]# ln -sv /usr/local/python27/bin/python2.7 /usr/bin/python27 `/usr/bin/python27' -> `/usr/local/python27/bin/python2.7' [root@kcw ipython-2.3.0]# ln -sv /usr/local/python27/bin/ipython /usr/bin/ `/usr/bin/ipython' -> `/usr/local/python27/bin/ipython'
这样在bash里面直接使用就可以了,注意你的系统里就有2个版本的python和一个iPython了,直接使用就行。
[root@kcw ipython-2.3.0]# python27 Python 2.7.8 (default, Oct 26 2014, 20:29:45) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> [root@kcw ipython-2.3.0]# ipython WARNING: IPython History requires SQLite, your history will not be saved Python 2.7.8 (default, Oct 26 2014, 20:29:45) Type "copyright", "credits" or "license" for more information. IPython 2.3.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]:
最后直接写了个脚本
#!/bin/bash # #rpm -q python #升级python为2.7 注意不要卸载系统自带的python,因为系统自带的好多软件依赖自带的python dir=/tmp/iPython file=Python-2.7.8.tar.xz file2=ipython-2.3.1.tar.gz num=`rpm -q python|grep python-2.7` #判断你当前系统上的python 如果是2.7 请单独安装ipython即可 if [ $? -eq 0 ] then echo "你的python版本是2.7及以上,请单独安装iPython Usage:yum install ipython 或者看下面安装ipython的方法即可" exit 0 fi ############################################################################################ if [ -d $dir ] then echo "iPython exist" else sudo mkdir iPython fi ############################################################################################ cd iPython if [ -f $file ] then echo "$file is exist" tar xf Python-2.7.8.tar.xz cd Python-2.7.8 ./configure --prefix=/usr/local/python27 sudo make && make install else wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz tar xf Python-2.7.8.tar.xz cd Python-2.7.8 sudo ./configure --prefix=/usr/local/python27 sudo make && make install fi ############################################################################################## #iPython 安装 依赖python2.7 if [ -f $file2 ] then echo "$file1 is exist" tar xf ipython-2.3.1.tar.gz cd ipython-2.3.1 sudo /usr/local/python27/bin/python2.7 setup.py build sudo /usr/local/python27/bin/python2.7 setup.py install else wget https://pypi.python.org/packages/source/i/ipython/ipython-2.3.1.tar.gz#md5=2b7085525dac11190bfb45bb8ec8dcbf tar xf ipython-2.3.1.tar.gz cd ipython-2.3.1 sudo /usr/local/python27/bin/python2.7 setup.py build sudo /usr/local/python27/bin/python2.7 setup.py install fi #安装完成后为了添加软链接以便直接使用,注意这时候你有2个python一个是python27这是新版本的python和你系统自带的python sudo ln -sv /usr/local/python27/bin/python2.7 /usr/bin/python27 sudo ln -sv /usr/local/python27/bin/ipython /usr/bin/
如果报错
[root@kcw ipython-2.3.1]# ipython Traceback (most recent call last): File "/usr/bin/ipython", line 5, in <module> from IPython.frontend.terminal.ipapp import launch_new_instance File "/usr/lib/python2.6/site-packages/IPython/__init__.py", line 43, in <module> from .config.loader import Config File "/usr/lib/python2.6/site-packages/IPython/config/__init__.py", line 16, in <module> from .application import * File "/usr/lib/python2.6/site-packages/IPython/config/application.py", line 31, in <module> from IPython.config.configurable import SingletonConfigurable File "/usr/lib/python2.6/site-packages/IPython/config/configurable.py", line 26, in <module> from loader import Config File "/usr/lib/python2.6/site-packages/IPython/config/loader.py", line 26, in <module> from IPython.external import argparse File "/usr/lib/python2.6/site-packages/IPython/external/argparse/__init__.py", line 10, in <module> from _argparse import * ImportError: No module named _argparse
请安装
[root@kcw ipython-2.3.1]# yum install *argparse* 已加载插件:fastestmirror, refresh-packagekit, security 设置安装进程 Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com 解决依赖关系 --> 执行事务检查 ---> Package nodejs-argparse.noarch 0:0.1.15-8.el6 will be 安装 --> 处理依赖关系 npm(underscore.string) < 2.4,它被软件包 nodejs-argparse-0.1.15-8.el6.noarch 需要 --> 处理依赖关系 npm(underscore) < 2,它被软件包 nodejs-argparse-0.1.15-8.el6.noarch 需要 --> 处理依赖关系 npm(underscore.string) >= 2.3.1,它被软件包 nodejs-argparse-0.1.15-8.el6.noarch 需要 --> 处理依赖关系 npm(underscore) >= 1.4,它被软件包 nodejs-argparse-0.1.15-8.el6.noarch 需要 --> 处理依赖关系 nodejs(engine) >= 0.6.0,它被软件包 nodejs-argparse-0.1.15-8.el6.noarch 需要 ---> Package python-argparse.noarch 0:1.2.1-2.el6.centos will be 安装 --> 执行事务检查 ---> Package nodejs.x86_64 0:0.10.33-1.el6 will be 安装 --> 处理依赖关系 v8(x86-64) < 1:3.15,它被软件包 nodejs-0.10.33-1.el6.x86_64 需要 --> 处理依赖关系 v8(x86-64) >= 1:3.14.5.7,它被软件包 nodejs-0.10.33-1.el6.x86_64 需要 --> 处理依赖关系 libv8.so.3()(64bit),它被软件包 nodejs-0.10.33-1.el6.x86_64 需要 --> 处理依赖关系 libuv.so.0.10()(64bit),它被软件包 nodejs-0.10.33-1.el6.x86_64 需要 --> 处理依赖关系 libhttp_parser.so.2()(64bit),它被软件包 nodejs-0.10.33-1.el6.x86_64 需要 --> 处理依赖关系 libcares19.so.2()(64bit),它被软件包 nodejs-0.10.33-1.el6.x86_64 需要 ---> Package nodejs-underscore.noarch 0:1.6.0-3.el6 will be 安装 ---> Package nodejs-underscore-dot-string.noarch 0:2.3.1-3.el6 will be 安装 --> 执行事务检查 ---> Package c-ares19.x86_64 0:1.9.1-5.el6.3 will be 安装 ---> Package http-parser.x86_64 0:2.0-4.20121128gitcd01361.el6 will be 安装 ---> Package libuv.x86_64 1:0.10.29-1.el6 will be 安装 ---> Package v8.x86_64 1:3.14.5.10-14.el6 will be 安装 --> 处理依赖关系 libicuuc.so.42()(64bit),它被软件包 1:v8-3.14.5.10-14.el6.x86_64 需要 --> 处理依赖关系 libicui18n.so.42()(64bit),它被软件包 1:v8-3.14.5.10-14.el6.x86_64 需要 --> 处理依赖关系 libicudata.so.42()(64bit),它被软件包 1:v8-3.14.5.10-14.el6.x86_64 需要 --> 执行事务检查 ---> Package libicu.x86_64 0:4.2.1-9.1.el6_2 will be 安装 --> 完成依赖关系计算 依赖关系解决 ================================================================================ 软件包 架构 版本 仓库 大小 ================================================================================ 正在安装: nodejs-argparse noarch 0.1.15-8.el6 epel 38 k python-argparse noarch 1.2.1-2.el6.centos extras 48 k 为依赖而安装: c-ares19 x86_64 1.9.1-5.el6.3 epel 73 k http-parser x86_64 2.0-4.20121128gitcd01361.el6 epel 22 k libicu x86_64 4.2.1-9.1.el6_2 base 4.9 M libuv x86_64 1:0.10.29-1.el6 epel 56 k nodejs x86_64 0.10.33-1.el6 epel 500 k nodejs-underscore noarch 1.6.0-3.el6 epel 32 k nodejs-underscore-dot-string noarch 2.3.1-3.el6 epel 15 k v8 x86_64 1:3.14.5.10-14.el6 epel 3.0 M 事务概要 ================================================================================ Install 10 Package(s) 总下载量:8.7 M Installed size: 31 M 确定吗?[y/N]:y 下载软件包: (1/10): c-ares19-1.9.1-5.el6.3.x86_64.rpm | 73 kB 00:00 (2/10): http-parser-2.0-4.20121128gitcd01361.el6.x86_64. | 22 kB 00:00 (3/10): libicu-4.2.1-9.1.el6_2.x86_64.rpm | 4.9 MB 00:01 (4/10): libuv-0.10.29-1.el6.x86_64.rpm | 56 kB 00:00 (5/10): nodejs-0.10.33-1.el6.x86_64.rpm | 500 kB 00:00 (6/10): nodejs-argparse-0.1.15-8.el6.noarch.rpm | 38 kB 00:00 (7/10): nodejs-underscore-1.6.0-3.el6.noarch.rpm | 32 kB 00:00 (8/10): nodejs-underscore-dot-string-2.3.1-3.el6.noarch. | 15 kB 00:00 (9/10): python-argparse-1.2.1-2.el6.centos.noarch.rpm | 48 kB 00:00 (10/10): v8-3.14.5.10-14.el6.x86_64.rpm | 3.0 MB 00:01 -------------------------------------------------------------------------------- 总计 2.4 MB/s | 8.7 MB 00:03 运行 rpm_check_debug 执行事务测试 事务测试成功 执行事务 正在安装 : http-parser-2.0-4.20121128gitcd01361.el6.x86_64 1/10 正在安装 : libicu-4.2.1-9.1.el6_2.x86_64 2/10 正在安装 : 1:v8-3.14.5.10-14.el6.x86_64 3/10 正在安装 : c-ares19-1.9.1-5.el6.3.x86_64 4/10 正在安装 : 1:libuv-0.10.29-1.el6.x86_64 5/10 正在安装 : nodejs-0.10.33-1.el6.x86_64 6/10 正在安装 : nodejs-underscore-dot-string-2.3.1-3.el6.noarch 7/10 正在安装 : nodejs-underscore-1.6.0-3.el6.noarch 8/10 正在安装 : nodejs-argparse-0.1.15-8.el6.noarch 9/10 正在安装 : python-argparse-1.2.1-2.el6.centos.noarch 10/10 Verifying : nodejs-0.10.33-1.el6.x86_64 1/10 Verifying : 1:libuv-0.10.29-1.el6.x86_64 2/10 Verifying : python-argparse-1.2.1-2.el6.centos.noarch 3/10 Verifying : nodejs-underscore-dot-string-2.3.1-3.el6.noarch 4/10 Verifying : c-ares19-1.9.1-5.el6.3.x86_64 5/10 Verifying : libicu-4.2.1-9.1.el6_2.x86_64 6/10 Verifying : nodejs-argparse-0.1.15-8.el6.noarch 7/10 Verifying : 1:v8-3.14.5.10-14.el6.x86_64 8/10 Verifying : http-parser-2.0-4.20121128gitcd01361.el6.x86_64 9/10 Verifying : nodejs-underscore-1.6.0-3.el6.noarch 10/10 已安装: nodejs-argparse.noarch 0:0.1.15-8.el6 python-argparse.noarch 0:1.2.1-2.el6.centos 作为依赖被安装: c-ares19.x86_64 0:1.9.1-5.el6.3 http-parser.x86_64 0:2.0-4.20121128gitcd01361.el6 libicu.x86_64 0:4.2.1-9.1.el6_2 libuv.x86_64 1:0.10.29-1.el6 nodejs.x86_64 0:0.10.33-1.el6 nodejs-underscore.noarch 0:1.6.0-3.el6 nodejs-underscore-dot-string.noarch 0:2.3.1-3.el6 v8.x86_64 1:3.14.5.10-14.el6 完毕! [root@kcw ipython-2.3.1]# ipython Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36) Type "copyright", "credits" or "license" for more information. IPython 0.13.2 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: