6

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?

Machavity
  • 30,841
  • 27
  • 92
  • 100
hwjp
  • 15,359
  • 7
  • 71
  • 70
  • some modules use C/C++ code and authors decide to not compile it. You don't compile on your own - pip does it for you. I never had problem with compilation of lxml on Linux Mint (based on Ubuntu 14.04) – furas Dec 14 '16 at 14:58
  • if you want precomiled lxml then use [Anaconda](https://docs.continuum.io/anaconda/pkg-docs) - it installs Python and has precompiled lxml and other modules for this Python version. – furas Dec 14 '16 at 15:00
  • thanks @furas, I can actually install the package just fine, my question is about why pip wants to compile even though a precompiled wheel is available. have clarified my post. – hwjp Dec 16 '16 at 13:22
  • 2
    What pip version do you have installed? What wheel version? – Lukasa Dec 16 '16 at 13:25
  • 2
    you have `Using cached lxml-3.6.4.tar.gz` so maybe try with `--no-cache-dir` – furas Dec 16 '16 at 14:02
  • I've just tried this on Ubuntu 16.04 using pip 9.0.1 and couldn't reproduce the issue: the manylinux wheel was downloaded and installed directly. Just running `pip install lxml` did reproduce, but that's because there are not (yet) any wheels for this version. – D. Evans Dec 16 '16 at 14:23

1 Answers1

3

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
hwjp
  • 15,359
  • 7
  • 71
  • 70