Centos ipython安装

准备环境:

yum install gcc make  zlib zlib-devel readline-devel patch openssl-devel

gcc make:安装编译器。zlib:用于python egg安装。readline-devel patch:用于readline模块的申明和头文件等,给使用了readline模块的程序提供编译支持(readline是ipython代码自动补完,自动缩进,高亮显示)。openssl-devel:用于easy_install使用,否则会提示unknown url type且补装后还需要重新编译python所以在此全部安装。ncurses:据说还需要此包,但我的环境中本来就有。


下载并解压Python包,需要使用--no-check-certificate参数,否则会报certificate common name:

wget --no-check-certificate http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar xvf Python-2.7.3.tgz

进入对应文件并编译:

cd Python-2.7.3
./configure
make && make install

configure,生成Makefile,为编译做准备。make,编译。make insatll,安装。



替换默认python:

mv /usr/bin/python /usr/bin/pythonOld2.6
ln -s /usr/local/bin/python2.7 /usr/bin/python 

查看是否替换成功(2.7版本即替换成功):

python -V

由于yum得使用旧python才能正常运行,所以修改yum文件将其指向旧python:

vim /usr/bin/yum
#!/usr/bin/pythonOld2.6


下载并安装setuptools,方便使用easy_install安装模块:

wget --no-check-certificate https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
sh setuptools-0.6c11-py2.7.egg

下载并解压readline模块,用于 代码自动补完, 自动缩进,高亮显示:

wget --no-check-certificate https://pypi.python.org/packages/source/r/readline/readline-6.2.4.1.tar.gz
tar zxvf readline-6.2.4.1.tar.gz
cd readline-6.2.4.1

安装readline模块(会提示缺少libreadline.a与libhistory.a):

easy_install readline

查找 libreadline.a与libhistory.a:

[root@bogon readline-6.2.4.1]# find / -name libread*
/lib64/libreadline.so.6.0
/lib64/libreadline.so.6
/tmp/readline-6.2.4.1/rl/readline-lib/libreadline.a
/tmp/readline-6.2.4.1/rl/readline-lib/shlib/libreadline.so.6.2
/usr/lib64/libreadline.so
[root@bogon readline-6.2.4.1]# find / -name libhist*
/tmp/readline-6.2.4.1/rl/readline-lib/libhistory.a
/tmp/readline-6.2.4.1/rl/readline-lib/shlib/libhistory.so.6.2
/usr/lib64/libhistory.so
/usr/lib64/libhistory.so.6.0
/usr/lib64/libhistory.so.6


修改readline模块包里的setup.py(110行,将查找路径修改为上一步找到的路径):

vi setup.py
extra_objects=['/tmp/readline-6.2.4.1/rl/readline-lib/libreadline.a', '/tmp/readline-6.2.4.1/rl/readline-lib/libhistory.a'],


再安装readline模块:

easy_install install ipython


进入ipython

ipython
WARNING: IPython History requires SQLite, your history will not be saved
Python 2.7.3 (default, Jan  9 2015, 15:53:49)
Type "copyright", "credits" or "license" for more information.

IPython 2.3.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]:


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值