Linux 系统安装 ipython 时遇到的报错

背景:

记录一下本人在Linux系统上安装 ipython 时遇到的情况。
  我的环境:CentOS6.8,Python2.7.13,pip-19.0.3,setuptools-40.8.0,之前的文章提到过CentOS6.8默认带的python为2.6,现在给升了Python2.7。

过程:
pip install ipython 命令安装时的报错:
(py27) [root@VM_0_15_centos venvs]# pip install ipython
DEPRECATION: Python 2.7 will reach the end of its life on January 1st,2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Collecting ipython
  Downloading http://mirrors.tencentyun.com/pypi/packages/e3/88/39c8b7701b2f7d5c8f3a1796b0c174f21071232bc5b242feb670e913acc6/ipython-7.4.0.tar.gz (5.1MB)
    100% |????????????????????????????????| 5.1MB 71.4MB/s 
    Complete output from command python setup.py egg_info:
    
    IPython 7.0+ supports Python 3.5 and above.
    When using Python 2.7,please install IPython 5.x LTS Long Term Support version.
    Python 3.3 and 3.4 were supported up to IPython 6.x.
        
    See IPython `README.rst` file for more information:    
        https://github.com/ipython/ipython/blob/master/README.rst  
    Python sys.version_info(major=2,minor=7,micro=13,releaselevel='final',serial=0) detected.
      
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-tr5Lsq/ipython/

于是上网查了下,找到这个 pip安装出现Command “python setup.py egg_info” failed with error code 1 的解决方案 ,这里提到的解决方案是更新 pip和setuptools的版本。但我的环境这两个已经是目前最新的了,如下:

[root@VM_0_15_centos lib]# pip list
Package                            Version
---------------------------------- ------- 
pip                                19.0.3 
setuptools                         40.8.0 

easy_install ipython 安装时报错:

[root@VM_0_15_centos chen]# easy_install ipython
Searching for ipython
Reading http://mirrors.tencentyun.com/pypi/simple/ipython/
Downloading http://mirrors.tencentyun.com/pypi/packages/e3/88/39c8b7701b2f7d5c8f3a1796b0c174f21071232bc5b242feb670e913acc6/ipython-7.4.0.tar.gz#md5=826178c87b7b96651ce8b26a779e3016
Best match: ipython 7.4.0
Processing ipython-7.4.0.tar.gz
Writing /tmp/easy_install-T3OSkd/ipython-7.4.0/setup.cfg
Running ipython-7.4.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-T3OSkd/ipython-7.4.0/egg-dist-tmp-oQ_xS0

IPython 7.0+ supports Python 3.5 and above.
When using Python 2.7,please install IPython 5.x LTS Long Term Support version.
Python 3.3 and 3.4 were supported up to IPython 6.x.

See IPython `README.rst` file for more information:
    https://github.com/ipython/ipython/blob/master/README.rst
Python sys.version_info(major=2,minor=7,micro=13,releaselevel='final',serial=0) detected.

error: Setup script exited with 1

yum install python-ipython.noarch 即用系统的软件包管理器进行安装:

参照 linux centos ubentu安装IPython四种方法 方法三,安装如下:

[root@VM_0_15_centos chen]# yum install python-ipython.noarch
Loaded plugins: fastestmirror,security
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package python-ipython.noarch 0:0.13.2-7.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================
 Package                Arch            Version                  Repository                Size
========================================================================================================
Installing:
 python-ipython         noarch          0.13.2-7.el6             epel                      11 k

很顺利的安装完了(安装过程中可能会自动安装一些依赖包),接着运行 ipython 又有新的报错:

[root@VM_0_15_centos chen]# ipython 
Traceback (most recent call last):
  File "/usr/bin/ipython",line 5,in <module>
    from IPython.frontend.terminal.ipapp import launch_new_instance
ImportError: No module named IPython.frontend.terminal.ipapp

额,这就难受了。网上查这个报错的 解决方案

[root@VM_0_15_centos chen]# vi /usr/bin/ipython
#编辑内容如下:
#!/usr/bin/python
"""Terminal-based IPython entry point.
"""
import sys
if "/usr/lib/python2.6/site-packages" not in sys.path:
    sys.path.append("/usr/lib/python2.6/site-packages")

from IPython.frontend.terminal.ipapp import launch_new_instance
launch_new_instance()

再运行 ipython 成功了!!!

[root@VM_0_15_centos lib]# ipython
WARNING: Readline services not available or not loaded.WARNING: The auto-indent feature requires the readline libraryPython 2.7.13 (default,Mar 29 2019,12:18:25) 
Type "copyright","credits" or "license" for more information.

IPython 0.13.2 -- 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]: 

等等~,ipython 版本 0.13.2 ,R U kidding me ??? 这版本太低了吧。其实前边执行 yum install python-ipython.noarch 时的输出信息就已经告诉了安装的 ipython 版本信息。为什么会这样呢? 仔细回想了下,之前在升级 Python2.6 到 Python2.7 时,曾修改过yum的配置文件 /usr/bin/yum 把yum的python编译环境改为了系统自带的python版本2.6(yum 安装工具只支持系统自带的python版本),而yum源自带的ipython包就是这么老。

查找问题解决方案过程中,看到了一些类似的问题这里贴下链接,供参考:

好吧,接下来换个方法吧…

尝试着进行源码安装:

ipython的源码下载页面为:https://pypi.org/project/ipython/#history
进去之后,发现 ipython 那么多版本呀,python2.7.13要安装哪个呢?选择恐惧症犯病了。。。等等。。。之前我用 pip install ipythoneasy_install ipython 命令安装的时候,看到了以下几行信息:

IPython 7.0+ supports Python 3.5 and above.
When using Python 2.7,please install IPython 5.x LTS Long Term Support version.
Python 3.3 and 3.4 were supported up to IPython 6.x.

额,原来 Python2.7 需要安装对应的 ipython5.x 系列的,那就来个ipython5.7的吧。
选完版本后,在 https://pypi.org/project/ipython/5.7.0/ 页面惊奇地发现 页面左上角清清楚楚给了命令 pip install ipython==5.7.0
直接粘贴执行:

[root@VM_0_15_centos ~]# pip install ipython==5.7.0
DEPRECATION: Python 2.7 will reach the end of its life on January 1st,2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Collecting ipython==5.7.0
  Downloading http://mirrors.tencentyun.com/pypi/packages/52/19/aadde98d6bde1667d0bf431fb2d22451f880aaa373e0a241c7e7cb5815a0/ipython-5.7.0-py2-none-any.whl (760kB)
    100% |████████████████████████████████| 768kB 8.5MB/s 
Requirement already satisfied: simplegeneric>0.8 in /chen/mysoft/python/lib/python2.7/site-packages (from ipython==5.7.0) (0.8.1)
...
Installing collected packages: ipython
  The scripts iptest,iptest2,ipython and ipython2 are installed in '/chen/mysoft/python/bin' which is not on PATH.
  Consider adding this directory to PATH or,if you prefer to suppress this warning,use --no-warn-script-location.
Successfully installed ipython-5.7.0

哇呜,安装成功了,运行一下:

[root@VM_0_15_centos ~]# ipython
/chen/mysoft/python/lib/python2.7/site-packages/IPython/frontend.py:21: ShimWarning: The top-level `frontend` package has been deprecated since IPython 1.0. All its subpackages have been moved to the top `IPython` level.
  "All its subpackages have been moved to the top `IPython` level.",ShimWarning)
Python 2.7.13 (default,"credits" or "license" for more information.

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

嘿嘿,也成功了,不过有个 Warning 信息,看着不爽??? 点我看看怎么解决吧


再试试 easy_install ipython 命令(虚拟环境下):

(myenv) [root@VM_0_15_centos venvs]# easy_install ipython==5.6.0
Searching for ipython==5.6.0
Reading http://mirrors.tencentyun.com/pypi/simple/ipython/
Downloading http://mirrors.tencentyun.com/pypi/packages/16/af/fbc5ecbb283344365ac98079524f8d61fd1b2afcef31d469023cba80b439/ipython-5.6.0-py2-none-any.whl#md5=e208f5df634ca557501f8d41fdb3838f
Best match: ipython 5.6.0
Processing ipython-5.6.0-py2-none-any.whl
Installing ipython-5.6.0-py2-none-any.whl to /chen/venvs/myenv/lib/python2.7/site-packages
writing requirements to /chen/venvs/myenv/lib/python2.7/site-packages/ipython-5.6.0-py2.7.egg/EGG-INFO/requires.txt
Adding ipython 5.6.0 to easy-install.pth file
Installing ipython script to /chen/venvs/myenv/bin
Installing iptest2 script to /chen/venvs/myenv/bin
Installing iptest script to /chen/venvs/myenv/bin
Installing ipython2 script to /chen/venvs/myenv/bin

Installed /chen/venvs/myenv/lib/python2.7/site-packages/ipython-5.6.0-py2.7.egg
Processing dependencies for ipython==5.6.0
... #一堆依赖包在进行下载安装
Finished processing dependencies for ipython==5.6.0

运行 ipython 看看:

(myenv) [root@VM_0_15_centos venvs]# ipython
Python 2.7.13 (default,"credits" or "license" for more information.

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

你是不是发现,这一节我本来是要进行源码安装 ipython 的,结果还是再说 pip 和 easy_install 安装。是的,我最开始用这两个命令的时候,不知道可以指定 ipython 版本号进行安装。导致后边走了好多弯路,又徒增了几根白发,哎~
累了,不想搞了,想看源码安装的,请移步其他人的博客。

原文地址:https://blog.csdn.net/B11050729/article/details/88916389

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Python中的函数(二) 在上一篇文章中提到了Python中函数的定义和使用,在这篇文章里我们来讨论下关于函数的一些更深的话题。在学习C语言函数的时候,遇到的问题主要有形参实参的区别、参数的传递和改变、变量的作用域。同样在Python中,关于对函数的理解和使用也存在这些问题。下面来逐一讲解。一.函
Python中的字符串 可能大多数人在学习C语言的时候,最先接触的数据类型就是字符串,因为大多教程都是以&quot;Hello world&quot;这个程序作为入门程序,这个程序中要打印的&quot;Hello world&quot;就是字符串。如果你做过自然语言处理方面的研究,并且用Python
Python 面向对象编程(一) 虽然Python是解释性语言,但是它是面向对象的,能够进行对象编程。下面就来了解一下如何在Python中进行对象编程。一.如何定义一个类 在进行python面向对象编程之前,先来了解几个术语:类,类对象,实例对象,属性,函数和方法。 类是对现实世界中一些事物的封装,
Python面向对象编程(二) 在前面一篇文章中谈到了类的基本定义和使用方法,这只体现了面向对象编程的三大特点之一:封装。下面就来了解一下另外两大特征:继承和多态。 在Python中,如果需要的话,可以让一个类去继承一个类,被继承的类称为父类或者超类、也可以称作基类,继承的类称为子类。并且Pytho
Python中的函数(一) 接触过C语言的朋友对函数这个词肯定非常熟悉,无论在哪门编程语言当中,函数(当然在某些语言里称作方法,意义是相同的)都扮演着至关重要的角色。今天就来了解一下Python中的函数用法。一.函数的定义 在某些编程语言当中,函数声明和函数定义是区分开的(在这些编程语言当中函数声明
在windows下如何快速搭建web.py开发框架 用Python进行web开发的话有很多框架供选择,比如最出名的Django,tornado等,除了这些框架之外,有一个轻量级的框架使用起来也是非常方便和顺手,就是web.py。它由一名黑客所创建,但是不幸的是这位创建者于2013年自杀了。据说现在由
将Sublime Text 2搭建成一个好用的IDE 说起编辑器,可能大部分人要推荐的是Vim和Emacs,本人用过Vim,功能确实强大,但是不是很习惯,之前一直有朋友推荐SUblime Text 2这款编辑器,然后这段时间就试了一下,就深深地喜欢上这款编辑器了...
Python中的模块 有过C语言编程经验的朋友都知道在C语言中如果要引用sqrt这个函数,必须用语句&quot;#include&lt;math.h&gt;&quot;引入math.h这个头文件,否则是无法正常进行调用的。那么在Python中,如果要引用一些内置的函数,该怎么处理呢?在Python中
Python的基础语法 在对Python有了基础的认识之后,下面来了解一下Python的基础语法,看看它和C语言、java之间的基础语法差异。一.变量、表达式和语句 Python中的语句也称作命令,比如print &quot;hello python&quot;这就是一条语句。 表达式,顾名思义,是
Eclipse+PyDevʽjango+Mysql搭建Python web开发环境 Python的web框架有很多,目前主流的有Django、Tornado、Web.py等,最流行的要属Django了,也是被大家最看好的框架之一。下面就来讲讲如何搭建Django的开发环境。一.准备工作 需要下载的
在windows下安装配置Ulipad 今天推荐一款轻便的文本编辑器Ulipad,用来写一些小的Python脚本非常方便。 Ulipad下载地址: https://github.com/limodou/ulipad http://files.cnblogs.com/dolphin0520/u...
Python中的函数(三) 在前面两篇文章中已经探讨了函数的一些相关用法,下面一起来了解一下函数参数类型的问题。在C语言中,调用函数时必须依照函数定义时的参数个数以及类型来传递参数,否则将会发生错误,这个是严格进行规定的。然而在Python中函数参数定义和传递的方式相比而言就灵活多了。一.函数参数的
在Notepad++中搭配Python开发环境 Python在最近几年一度成为最流行的语言之一,不仅仅是因为它简洁明了,更在于它的功能之强大。它不仅能够完成一般脚本语言所能做的事情,还能很方便快捷地进行大规模的项目开发。在学习Python之前我们来看一下Python的历史由来,&quot;Pytho
Python中的条件选择和循环语句 同C语言、Java一样,Python中也存在条件选择和循环语句,其风格和C语言、java的很类似,但是在写法和用法上还是有一些区别。今天就让我们一起来了解一下。一.条件选择语句 Python中条件选择语句的关键字为:if 、elif 、else这三个。其基本形式如
关于raw_input( )和sys.stdin.readline( )的区别 之前一直认为用raw_input( )和sys.stdin.readline( )来获取输入的效果完全相同,但是最近在写程序时有类似这样一段代码:import sysline = sys.stdin.readline()
初识Python 跟学习所有的编程语言一样,首先得了解这门语言的编程风格和最基础的语法。下面就让我们一起来了解一下Python的编程风格。1.逻辑行与物理行 在Python中有逻辑行和物理行这个概念,物理行是指在编辑器中实际看到的一行,逻辑行是指一条Python语句。在Python中提倡一个物理行只
当我们的代码是有访问网络相关的操作时,比如http请求或者访问远程数据库,经常可能会发生一些错误,有些错误可能重新去发送请求就会成功,本文分析常见可能需要重试的场景,并最后给出python代码实现。
1.经典迭代器 2.将Sentence中的__iter__改成生成器函数 改成生成器后用法不变,但更加简洁。 3.惰性实现 当列表比较大,占内存较大时,我们可以采用惰性实现,每次只读取一个元素到内存。 或者使用更简洁的生成器表达式 4.yield from itertools模块含有大量生成器函数可
本文介绍简单介绍socket的常用函数,并以python-kafka中的源码socketpair为例,来讲解python socket的运用
python实践中经常出现编码相关的异常,大多网上找资料而没有理解原理,导致一次次重复错误。本文对常用Unicode、UTF-8、GB2312编码的原理进行介绍,接着介绍了python字符类型unicode和str以及常见编解码错误UnicodeEncodeError和UnicodeDEcodeEr