【问题标题】:Not able to install lxml verison 3.3.5 in ubuntu无法在 ubuntu 中安装 lxml 版本 3.3.5
【发布时间】:2014-06-27 13:34:24
【问题描述】:

我在我的应用程序中使用 openpyxl python 包。使用相同时我收到以下消息。

/usr/local/lib/python2.7/dist-packages/openpyxl/init.py:31: 用户警告:安装的 lxml 版本太旧,无法使用 打开pyxl

warnings.warn("安装的lxml版本太旧,无法与openpyxl一起使用")

openpyxl需要lxml 3.2.5或以上版本,我机器中的版本是3.2.0。当我尝试将 lxml 升级到最新版本时,即 3.3.5,它被以下消息打断。

i686-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-i686-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-i686-2.7/lxml/etree.so

/usr/bin/ld: cannot find -lz

collect2: error: ld returned 1 exit status

error: command 'i686-linux-gnu-gcc' failed with exit status 1

----------------------------------------

  Rolling back uninstall of lxml

  Replacing /usr/lib/python2.7/dist-packages/lxml
  Replacing /usr/lib/python2.7/dist-packages/lxml-3.2.0.egg-info
Cleaning up...

  Removing temporary dir /tmp/pip_build_root...
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ov0PUy-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip_build_root/lxml

我需要帮助来解决问题。

PS:- 我已经在我的机器上安装了 lxml 依赖包 python-dev、libxml2-dev 和 libxslt1-dev。

【问题讨论】:

  • 注意,lxml 实际上只需要用于测试,但我认为我们需要检查它是否存在更好的处理。我建议始终使用 virtualenv,以便您决定是否需要 lxml。目前,lxml 读取文件的速度似乎较慢。

标签: python lxml openpyxl


【解决方案1】:
sudo pip install --upgrade lxml

【讨论】:

    【解决方案2】:

    我认为你缺少的是 zlib1g-dev。

    sudo apt-get install zlib1g-dev
    

    运行上述命令将解决问题。

    【讨论】:

    • 感谢您的回复。您的建议解决了这个问题。
    【解决方案3】:

    在 Ubuntu(和其他 Debian 衍生产品)上,在构建某些软件之前,请确保已安装其构建依赖项。使用您的示例,运行以下命令:

    sudo apt-get build-dep python-lxml
    

    这可能需要一大堆包,其中一个是 zlib1g-devas mentioned

    【讨论】:

      猜你喜欢
      • 2013-11-22
      • 2021-06-25
      • 1970-01-01
      • 2015-10-06
      • 1970-01-01
      • 2011-09-24
      • 2015-10-28
      • 2016-05-10
      • 1970-01-01
      相关资源
      最近更新 更多