Tuesday 19 May 2015

Pip install upgrade is failing with error message ImportError: cannot import name IncompleteRead

Sometimes suddenly pip stops working for no reason:

It happens when the version of pip we were using becomes outdated. And the error message we get is somewhat like this :

ubuntu@ip-127.0.0.1:~/utils$ sudo pip install --upgrade dist/utils-0.1.tar.gz 
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 351, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2363, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2088, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 61, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
    from pip.download import path_to_url
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in <module>
    from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead


To solve this we need to update pip :

sudo easy_install -U pip


This will resolve the problem.

Cheers,
Vikash