【问题标题】:Why does "pip install lxml" not use the provided wheel, and tries to compile anyway?为什么“pip install lxml”不使用提供的轮子,并尝试编译?
【发布时间】:2017-04-29 22:07:38
【问题描述】:

wheel 是分发预编译包以通过 pip 安装的新方法。

lxml entry on pypi 有可用于“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]

有什么想法吗?

【问题讨论】:

  • 一些模块使用 C/C++ 代码,作者决定不编译它。您不会自己编译 - pip 会为您完成。在 Linux Mint(基于 Ubuntu 14.04)上编译 lxml 时我从来没有遇到过问题
  • 如果你想要预编译的 lxml 然后使用Anaconda - 它会安装 Python 并为此 Python 版本预编译 lxml 和其他模块。
  • 感谢@furas,我实际上可以很好地安装软件包,我的问题是为什么 pip 想要编译,即使有预编译的轮子可用。已经澄清了我的帖子。
  • 你安装了什么pip版本?什么轮子版本?
  • 你有Using cached lxml-3.6.4.tar.gz,所以可以试试--no-cache-dir

标签: python ubuntu pip lxml python-wheel


【解决方案1】:

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

  • 在最小的复制中,pip 正在查找源的 .tar.gz 的缓存版本,并且只是使用它而不是在线检查任何轮子。 (HT @oldmanuk 和 @furas 发现了这一点)。 Aaaaaarguably 这是一个错误?无论如何,吸取教训,我的最小复制不是。

  • 在最初的问题中,我使用的是 Ubuntu Trusty。我知道旧版本的 pip 不能很好地做轮子(参见@lukasa,@_rami_)。我已经预料到了,并且在我的脚本中有一个pip install --upgrade pip。我没有注意到的是它实际上是因为消息 Not uninstalling pip at /usr/lib/python2.7/dist-packages, owned by OS 失败(根据 this issue),所以我仍然使用 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

【讨论】:

    猜你喜欢
    • 2016-05-12
    • 1970-01-01
    • 1970-01-01
    • 2017-02-28
    • 2021-09-14
    • 1970-01-01
    • 2012-10-12
    • 1970-01-01
    • 2017-12-20
    相关资源
    最近更新 更多