導語:
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]: