Heim  >  Artikel  >  Backend-Entwicklung  >  Linux中安装Python的交互式解释器IPython的教程

Linux中安装Python的交互式解释器IPython的教程

PHP中文网
PHP中文网Original
2016-06-16 08:47:511994Durchsuche

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

下面介绍下linux安装IPython四种方法:

第一种:ipython源码安装
ipython的源码下载页面为:https://pypi.python.org/pypi/ipython

或者是到git页面下载:https://github.com/ipython/ipython/downloads
假设我们下载的文件名为:ipython-0.8.2.tar.gz

#tar zvxf ipython-0.8.2.tar.gz  //解压文件
#cd ipython-0.8.2 //进入刚刚解压的文件夹内

进入文件加后会看到一个setup.py的安装脚本,运行以下命令进行安装

#python setup.py install

操作将会在site-packages目录中安装ipyhon的库文件,并在scripts目录中创建一个ipython脚本。在unix系统中,该目录与python的二进制文件目录相同。如果系统中已经安装了python包,则ipython将会安装在/usr/bin目录下。

第二种:通过系统的软件包管理器安装ipython软件包。
如.deb包可以在debian和ubuntu上获取,直接用以下命令:

#apt-get install ipython

//ubuntu将ipython的库文件安装到/usr/share/python-support/ipython目录下,包括一系列.pth文件和符号链接,而ipython的二进制文件则安装在/usr/bin/ipyton目录下。


 redhat(centos)使用下面的命令:

#yum list | grep ipython  //查看你所使用的yum源是否有ipython包,没有的话,就只能换源或者源码安装了,
国内貌似都没有

#yum install ipython.noarch  //安装ipython

或者是通过rpm包安装,命令如下:

#rpm -ivh https://dl.fedoraproject.org/pub/epel/6/x86_64/ipython-0.10-3.el6.noarch.rpm

第三种:通过python包进行安装。
在python包中包含了ipython。将python包解压后,可以看到一个扩展名为.egg的文件。Egg文件可以通过easy_install工具安装。  easy_install工具可以检查egg文件的配置,然后选择需要安装的内容。easy_install工具通过python包的索引(python package index ,简称PyPI,又被称作python cheeseshop)确定包的安装。使用easy_install工具安装ipython,只需要用户对site_package目录有写权限,直接运行

#easy_install ipython

Ps:前提是你已经安装了easy_install工具,所以你如果想用这种方法来安装,就要先安装setuptools才能用easy_install工具。

第四种:直接不安装就用.
下载ipython的源码后,运行ipython.py安装命令后,就可以使用该下载版本中的ipython实例了。这种方法能够使site-packages目录保持简明,但同时也会带来一些问题,那就是如果没有解压ipython,也就没有修改PYTHONPATH环境变量,ipython将不能作为一个库文件直接使用。

我个人建议还是源码安装吧

有问题的可以去官方查看安装文档教程:

http://ipython.org/ipython-doc/stable/install/install.html

http://ipython.org/install.html


PS:出现gcc: readline/libreadline.a报错
ipython这个工具非常好用,不过在linux下安装的时候却报了下面2个错。(环境是centos6.2,python2.7)

gcc: readline/libreadline.a: No such file or directory
gcc: readline/libhistory.a: No such file or directory

解决:
只需要

yum -y install readline-devel
yum -y install patch
pip install ipython

即可

以上就是Linux中安装Python的交互式解释器IPython的教程的内容,更多相关内容请关注PHP中文网(www.php.cn)!


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn