继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

交互式python shell之ipython安装

慕仙森
关注TA
已关注
手记 94
粉丝 36
获赞 103

导语:

IPython是Python的交互式Shell,提供了代码自动补完,自动缩进,高亮显示,执行Shell命令等非常有用的特性。特别是它的代码补完功能,例如:在输入zlib.之后按下Tab键,IPython会列出zlib模块下所有的属性、方法和类。完全可以取代自带的bash

两种安装方式:

1.yum安装(推荐)
2.手动下载源码包安装

yum安装方式:

2版本的ipython只需要安装epel源然后yum直接安装就可,不需要手动安装:

   [root@wing ~]#yum install epel-release -y
    [root@wing ~]#yum install ipython -y
    也可以直接用命令 # pip install ipython 安装

安装完之后即可运行ipython:

[root@wing Desktop]# ipython
Python 2.7.5 (default, Aug  4 2017, 00:39:18) 
Type "copyright", "credits" or "license" for more information.
IPython 3.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]:

3版本的ipython3安装只需要使用python3用下面命令安装即可

 [root@wing ~]# python3 -m pip install ipython 
    安装完运行ipython3:
    [root@wing ~]# ipython3
    Python 3.6.2 (default, Sep 14 2017, 15:13:07) 
    Type 'copyright', 'credits' or 'license' for more information
    IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
    In [1]:

到这里其实已经结束了,如果你纠结源码方式安装,接着往下看

手动从官网下载安装包的安装方式如下:
ipython下载:

    官网下载 :https://pypi.python.org/pypi/ipython    
    或者    
    git页下载:https://github.com/ipython/ipython/downloads

下载的安装包文件名为:
ipython-5.0.0.tar    
#注意只有1.0版本才支持2.6的python,其他高版本必须要python2.7以上
#tar zvxf ipython-5.0.0.tar   #解压
#cd ipython-5.0.0                #进入解压目录
#python setup.py  install     #安装
该操作将会在site-packages目录中安装ipyhon的库文件,并在scripts目录中创建一个
ipython脚本。在unix系统中,该目录与python的二进制文件目录相同,如果系统中已经安
装了python包,则ipython将会安装在/usr/bin目录下。

启动之后,报错:

  ImportError: No module named 'traitlets' ...   
  后面会报很多类似缺模块的错误,是因为缺依赖包

安装以下依赖模块:
所有依赖模块都是在https://pypi.python.org/pypi/这个网站下载(右上角搜索框直接搜索模块名称),这些模块的安装方式跟上面ipython的安装方式一样

 traitlets、ipython_genutils、decorator、pexpect、pickleshare、path.py、
 setuptools、setuptools_scm、simplegeneric、
 backports.shutil_get_terminal_size、ipython_genutils、prompt_toolkit、
 ptyprocess、Pygments

两个小时之后(我这网速也是..哎,泪奔),终于成功了!
意外:如果你用的是Debian系统,恭喜你,可以直接用最简单的方式从Debian系统镜像安装使用Ipython

做软连接

ln -s /usr/local/python2.7.10/bin/ipython  /usr/bin/

使用ipython,界面如下:

    [root@vm2 ~]# ipython 
    Python 2.7.10 (default, Aug 12 2016, 14:14:35) 
    Type "copyright", "credits" or "license" for more information.
    IPython 5.0.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]:

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP