交互式python shell之ipython安裝

導語:

IPython是Python的交互式Shell,提供了代碼自動補完,自動縮進,高亮顯示,執行Shell命令等很是有用的特性。特別是它的代碼補完功能,例如:在輸入zlib.以後按下Tab鍵,IPython會列出zlib模塊下全部的屬性、方法和類。徹底能夠取代自帶的bashpython

兩種安裝方式:

1.yum安裝(推薦)
2.手動下載源碼包安裝git

yum安裝方式:

2版本的ipython只須要安裝epel源而後yum直接安裝就可,不須要手動安裝:github

[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用下面命令安裝便可bash

[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]:

到這裏其實已經結束了,若是你糾結源碼方式安裝,接着往下看python2.7

手動從官網下載安裝包的安裝方式以下:
ipython下載:ide

官網下載 :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目錄下。網站

啓動以後,報錯:ui

ImportError: No module named 'traitlets' ... 
  後面會報不少相似缺模塊的錯誤,是由於缺依賴包

安裝如下依賴模塊:
全部依賴模塊都是在https://pypi.python.org/pypi/這個網站下載(右上角搜索框直接搜索模塊名稱),這些模塊的安裝方式跟上面ipython的安裝方式同樣unix

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系統鏡像安裝使用Ipythoncode

作軟鏈接

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]:
相關文章
相關標籤/搜索