您的位置:首页 > 编程语言 > Python开发

1.服务器上安装更新的python和代码提示(ipython)的安装

2016-01-16 20:20 761 查看
linux mint17.x和linux kali2等linux发行版本python版本已经都大家都在使用的2.7.6以上,但是面对我们的服务器centos5~6和redhat5~6往往python还是python2.6,但是当前服务器上众多软件都依赖于自带的python,这就需要我们在不卸载原有python的状况下使用新的版本。目前我们有两种方法,一种使用pyenv进行环境切换,一种使用源码包编译重新安装后在/usr/bin下创建软连接。这里我们使用第二种。单独安装python不具备使用Tab键进行代码提示的功效,我们安装ipython的库来添加这样一种功能。

首先你需要源码包:

python2.7.6百度云:http://pan.baidu.com/s/1pKcc6ev 密码:epev

ipython1.2.1百度云:链接:http://pan.baidu.com/s/1eRi04Rw 密码:8td0


提示:我没有在官网上找到ipython1.2.1的包,所以请使用该包的时候进行验证,以免存在安全问题。

找到你的python2.7.6源码包

[root@localhost ~]# tar -xf Python-2.7.6.tgz
进入解档解压文件夹下

[root@localhost ~]# tar -xf Python-2.7.6.tgz
[root@localhost Python-2.7.6]# ls
build          config.sub    Doc         Lib             Makefile         Modules  PCbuild         python         RISCOS
config.guess   configure     Grammar     libpython2.7.a  Makefile.pre     Objects  pybuilddir.txt  Python         setup.py
config.log     configure.ac  Include     LICENSE         Makefile.pre.in  Parser   pyconfig.h      python-gdb.py  Tools
config.status  Demo          install-sh  Mac             Misc             PC       pyconfig.h.in   README
在安装以前先解决一个问题,有可能你安装后退格键无法使用,需要解决一下依赖关系。(请先设置好yum源,我的博客中有详细写)

[root@localhost Python-2.7.6]# yum install readline


执行当前文件夹下configure,之后安装,记得指定一下自己的安装位置

[root@localhost Python-2.7.6]# ./configure --prefix=/usr/local/python27/
[root@localhost Python-2.7.6]# make && make install
创建链接文件

[root@localhost bin]# ln /usr/local/python27/bin/python2.7 /usr/bin/python27
到这里新版本的python就能使用了,执行

[root@localhost ~]# python27
Python 2.7.6 (default, Jan 15 2016, 21:27:22) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
安装ipython

解档解压缩

[root@localhost ~]# tar xf ipython-1.2.1.tar.gz
进入解压位置

[root@localhost ~]# cd ipython-1.2.1
安装ipython模块

[root@localhost ipython-1.2.1]# /usr/local/python27/bin/python2.7 setup.py build
[root@localhost ipython-1.2.1]# /usr/local/python27/bin/python2.7 setup.py install



创建链接

[root@localhost bin]# ln /usr/local/python27/bin/ipython /usr/bin/ipython
使用ipython

[root@localhost bin]# ipython 
Python 2.7.6 (default, Jan 15 2016, 21:27:22) 
Type "copyright", "credits" or "license" for more information.

IPython 1.2.1 -- 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]:
ok!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: