18

I am running into problems when ever I run pip with any arguments or flags. I've tried doing apt-get install --reinstall python-pip but it does not help and am at a loss how to fix this

Version of Ubuntu

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.1 LTS
Release:    14.04
Codename:   trusty

Version of Python

$ python --version
Python 2.7.6

Pip version

$ dpkg -l | grep pip
ii  python-pip     1.5.4-1     all     alternative Python package installer

Error, I get the exact same error no matter what arguments or flags I try.

$ pip
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 11, 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
3
  • 1
    What maybe solves this too is easy_install -U pip...
    – Byte Commander
    May 9, 2015 at 10:27
  • easy_install -U pip from ByteCommander suggestion worked for me.
    – Tampa
    Jun 1, 2015 at 12:23
  • This answer works for Linux (Ubuntu). Jul 1, 2018 at 6:15

6 Answers 6

15

Seems to be a bug that it is reported here

It should work if you install a later version of pip.

You can remove the current pip installation with:

sudo apt-get purge python-pip

Then install it from github(it is a later version):

wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
python get-pip.py

Edit
If it still won't work try this as it says so in the installation documentation(after you installed the new version):

To enable the use of pip from the command line, ensure the Scripts subdirectory of your Python installation is available on the system PATH. (This is not done automatically.)

References:

  1. https://pip.pypa.io/en/latest/installing.html
  2. https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1306991
1
  • 2
    This shouldn't be closed!!! Instead of wgetting that raw github file, follow pip.pypa.io/en/latest/installing.html. In a nutshell say 1. wget https://bootstrap.pypa.io/get-pip.py, then 2. sudo python get-pip.py
    – Csaba Toth
    Mar 11, 2015 at 21:57
3

This problem is caused by a mismatch between your pip installation and your requests installation. First remove the python-pip package and then install the latest version of pip. Open the terminal and type:

sudo apt remove python-pip
sudo apt install python-setuptools
sudo easy_install -U pip

To update pip for Python 3.x replace python-pip with python3-pip, replace python-setuptools with python3-setuptools, and replace easy_install with easy_install3.

2

Well, the get-pip.py script from github is outdated, and the latest version is on pypa as follows:

sudo apt-get purge python-pip

wget https://bootstrap.pypa.io/get-pip.py

python get-pip.py
2
  • Installation is working but after it pip cannot be found. When I type pip in command line I get bash: /usr/bin/pip: No such file or directory
    – mcExchange
    Mar 15, 2017 at 16:18
  • Try sudo python get-pip.py, it may help.(I'm a macOS user now, sorry for no testing env)
    – sstruct
    Apr 7, 2017 at 2:37
1

I had the same error and same Ubuntu versions. easy_install was not working either. Doing apt-get --reinstall had not worked.

You might try recompiling:

sudo python

>>>import compileall

>>>compileall.compile_dir('/usr/lib/python2.7', force=True)

now "pip list" works (I had previously removed all the pyc files but I don't think it is necessary or safe)

1

Create a Symbolic link to /user/bin

sudo ln -s /usr/local/bin/pip /usr/bin/

0

Reinstalling python-pip from this website worked for me:

sudo apt-get purge python-pip
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py --user

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .