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

在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 "", line 1, in 
      File "/private/tmp/pip-build-lyIITv/pexpect/setup.py", line 66, in 
        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

你可能感兴趣的:(python,mac,os,x,Python)