为什么“pip install lxml”不使用提供的轮子,而是尝试编译?

hwj*_*wjp 5 python ubuntu lxml pip python-wheel

一个轮子是通过PIP安装分发预编译包的新途径。

pypi上的lxml 条目具有可用于“manylinux”的轮子。我正在运行 ubuntu。

但是,当我尝试 pip install lxml 时,它似乎仍然尝试编译。任何想法为什么?

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]
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

hwj*_*wjp 3

感谢大家!所以我想我找到了答案。这里实际上有两个问题,第一个是我最初遇到错误时的问题,第二个是我创建最小重现(我在 q 中发布的)时的问题。

  • 在最小的重现中,pip 找到了源的.tar.gz的缓存版本,并且只是使用它而不是在线检查是否有任何轮子。(HT @oldmanuk 和 @furas 发现了这一点)。啊啊啊这可能是一个错误?不管怎样,吸取了教训,我的最小重现却没有。

  • 在最初的问题中,我使用的是 Ubuntu Trusty。我知道旧版本的 pip 不能很好地运行轮子(参见@lukasa,@_rami_)。我已经预料到了这一点,并且pip install --upgrade pip在我的剧本中也有这样的内容。我没有注意到的是,它实际上因消息而失败Not uninstalling pip at /usr/lib/python2.7/dist-packages, owned by OS(根据此问题),因此我仍在使用 pip 1.5.4,它忽略了轮子。

所以最终的解决办法是手动强制重新安装 pip

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
Run Code Online (Sandbox Code Playgroud)