安装ipython时python setup.py egg_info错误的解决办法

在Mac OS X中通过sudo pip install ipython安装IPython时遇到VersionConflict错误,主要是certifi版本冲突。解决方法包括:从官方源下载certifi后install from source,或者卸载现有certifi并安装指定版本;另一种方法是创建虚拟环境后再安装ipython。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在Mac OS X中安装IPython:

python -V
Python 2.7.6
pip -V
pip 8.1.1 from /Library/Python/2.7/site-packages (python 2.7)

使用sudo pip install ipython指令安装ipython,运行结果出现

The directory '/Users/home/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/home/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting ipython
/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading ipython-4.1.2-py2-none-any.whl (736kB)
    100% |████████████████████████████████| 737kB 25kB/s 
Requirement already satisfied (use --upgrade to upgrade): traitlets in /Library/Python/2.7/site-packages (from ipython)
Requirement already satisfied (use --upgrade to upgrade): pickleshare in /Library/Python/2.7/site-packages (from ipython)
Requirement already satisfied (use --upgrade to upgrade): simplegeneric>0.8 in /Library/Python/2.7/site-packages (from ipython)
Requirement already satisfied (use --upgrade to upgrade): setuptools>=18.5 in /Library/Python/2.7/site-packages (from ipython)
Requirement already satisfied (use --upgrade to upgrade): decorator in /Library/Python/2.7/site-packages (from ipython)
Requirement already satisfied (use --upgrade to upgrade): gnureadline in /Library/Python/2.7/site-packages (from ipython)
Requirement already satisfied (use --upgrade to upgrade): appnope in /Library/Python/2.7/site-packages (from ipython)
Collecting pexpect (from ipython)
  Downloading pexpect-4.0.1.tar.gz (143kB)
    100% |████████████████████████████████| 153kB 67kB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-build-lyIITv/pexpect/setup.py", line 66, in <module>
        install_requires=['ptyprocess>=0.5'],
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 112, in setup
        _setup_distribution = dist = klass(attrs)
      File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 225, in __init__
        _Distribution.__init__(self,attrs)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 287, in __init__
        self.finalize_options()
      File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 257, in finalize_options
        ep.require(installer=self.fetch_build_egg)
      File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2029, in require
        working_set.resolve(self.dist.requires(self.extras),env,installer))
      File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 592, in resolve
        raise VersionConflict(dist,req) # XXX put more info here
    pkg_resources.VersionConflict: (certifi 2016.2.28 (/Library/Python/2.7/site-packages), Requirement.parse('certifi==2015.11.20'))

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-lyIITv/pexpect/

主要错误为:
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (certifi 2016.2.28 (/Library/Python/2.7/site-packages), Requirement.parse(‘certifi==2015.11.20’))
为此楼主用尽了各种办法,比如
sudo pip install --upgrade setuptools
sudo pip install ipython --allow-all-external
结果都不work啊,抓狂中。。。
偶然发现了两个方法可有效解决此问题,可把楼主兴奋的~~~现贴出来与大家共享
方法一:
所有的问题出在certifi version conflict
所以可以从https://pypi.python.org/pypi/certifi 中下载,然后install from source
运行这句命令sudo python setup.py install 便可顺利解决此问题。
或者可以直接卸载certifi 2016.2.28sudo pip uninstall certifi
然后安装符合要求的certifi==2015.11.20。sudo pip install certifi==2015.11.20
为避免产生RuntimeError: maximum recursion depth exceeded 的错误
再更新distributepip install --upgrade distribute
方法二:
创建虚拟环境运行ipython

>>>pip install virtualenv
>>>virtualenv venv
>>>source venv/bin/activate

这时便已经进入了虚拟环境,现在便可使用pip install ipython 安装。
当你想退出这个虚拟环境时,使用命令

>>>deactivate
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值