Why does "pip install lxml" not use the provided wheel, and tries to compile anyway?

1.9k views Asked by At

A wheel is the new way of distributing pre-compiled packages for installation via pip.

The lxml entry on pypi has wheels available for "manylinux". I am running ubuntu.

However, when I try to pip install lxml, it seems to try and compile anyway. Any ideas why?

mktmpenv
pip install lxml==3.6.4

Collecting lxml==3.6.4
  Using cached lxml-3.6.4.tar.gz
Building wheels for collected packages: lxml
  Running setup.py bdist_wheel for lxml

  Complete output from command /home/harry/.virtualenvs/tmp-940224e01c89b3f0/bin/python3 -c "import setuptools;__file__='/tmp/pip-build-gxw05tyo/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmp78u4a871pip-wheel-:
  Building lxml version ....
  Building lxml version 3.6.4.
  Building without Cython.
  Using build configuration of libxslt 1.1.29
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.5
[...etc]

Any ideas?

1

There are 1 answers

0
hwjp On

Thanks everyone! So I think I found the answer. There were actually two problems here, the first when I initially encountered the bug, and the second when I created the minimal repro (which I posted in the q).

  • In the minimal repro, pip was finding a cached version of the .tar.gz of the sources, and was just using that instead of checking online for any wheels. (HT @oldmanuk and @furas for spotting that). Aaaaaarguably this is a bug? Anyway, lesson learned, my minimal repro wasn't.

  • In the original problem, I was on Ubuntu Trusty. I'm aware that older versions of pip don't do wheels well (cf @lukasa, @_rami_). I had anticipated that, and had a pip install --upgrade pip in my script. What I didn't notice is that it was actually failing with the message Not uninstalling pip at /usr/lib/python2.7/dist-packages, owned by OS (as per this issue) and so I was still on pip 1.5.4, which was ignoring wheels.

So the ultimate fix was to manually force reinstallation of pip with

apt-get remove -y python-pip
wget -q https://bootstrap.pypa.io/get-pip.py
python get-pip.py  # upgrade system pip to make sure we use wheels