Page 1 of 1

Python2 PIP broken after libxml,libxslt install

Posted: Thu Oct 20, 2016 6:12 pm
by E3V3A

I was installing a bunch of tools using:

Code: Select all

sudo pip install XXXX
Then eventually one tool tried to build lxml-3.6.0 and wanted libxml2-dev and libxslt1-dev to build.
Then another tool called Pillow 2.6.1 tried to install and failing with:

Code: Select all

  Can't roll back Pillow; was not uninstalled
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-S_9zQs/Pillow/';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ZY11aj-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-build-S_9zQs/Pillow
Storing debug log for failure in /root/.pip/pip.log
So I installed with:

Code: Select all

sudo apt-get install libxml2-dev libxslt-dev
After that, pip stopped working, altogether!

Code: Select all

$ pip list
Traceback (most recent call last):
  File "/usr/bin/pip2", line 9, in <module>
    load_entry_point('pip==1.5.6', 'console_scripts', 'pip2')()
  File "/usr/lib/python2.7/dist-packages/", line 356, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/", line 2476, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/", line 2190, in load
  File "/usr/lib/python2.7/dist-packages/pip/", line 74, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/usr/lib/python2.7/dist-packages/pip/vcs/", line 9, in <module>
    from import path_to_url
  File "/usr/lib/python2.7/dist-packages/pip/", line 25, in <module>
    from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead
No matter what I do. I also tried re-installing it with

Code: Select all

sudo apt-get install --reinstall python-pip
and that didn't work either.

Then I discovered that there are different versions of pip:

Code: Select all

pi@raspberrypi:~ $ ll /usr/bin/pip*
-rwxr-xr-x 1 root root   281 Feb 28  2015 /usr/bin/pip
-rwxr-xr-x 1 root root   283 Feb 28  2015 /usr/bin/pip2
-rwxr-xr-x 1 root root   284 Feb 28  2015 /usr/bin/pip3
lrwxrwxrwx 1 root root     4 Sep 23 06:52 /usr/bin/pip-3.2 -> pip3

Code: Select all

pip3 list
works, but not showing anything that was previously installed with pip (using Python2.7 AFAIK).

After an hour of trying various things I'm not any step closer to a resolution.
Any ideas what went wrong and how to fix this?

Re: Python2 PIP broken after libxml,libxslt install

Posted: Thu Oct 20, 2016 7:06 pm
by E3V3A
I managed to fix it with a work around. (Not sure yet, the effects on the system.)

Code: Select all

# remove old pip (Python2.7)
sudo apt-get remove python-pip

# Remove unused dependencies
sudo apt-get autoremove

# Make sure you get the scripts in: /usr/bin/ and not in its default: /usr/local/bin
sudo easy_install --script-dir /usr/bin/ pip

# Test:
$ pip3 --version
pip 1.5.6 from /usr/lib/python3/dist-packages (python 3.4)
$ pip --version
pip 8.1.2 from /usr/local/lib/python2.7/dist-packages/pip-8.1.2-py2.7.egg (python 2.7)
And all my previous pip installations are back! Awesome.