简体   繁体   English

无法在 virtualenv 中安装 libxml2

[英]cannot Install libxml2 in virtualenv

I have got an issue with libxml2 python module.我遇到了libxml2 python 模块的问题。

I'm trying to install it on a python3 virtualenv using the following command:我正在尝试使用以下命令将它安装在python3 virtualenv 上

pip install libxml2-python3

but it shows the following error:但它显示以下错误:

Collecting libxml2-python3   Using cached
https://files.pythonhosted.org/packages/41/97/a2ecf6c5b291799dbd40b3d041d89b0ecdb1b43c8c2503e27991325851cd/libxml2-python3-2.9.5.tar.gz
     Complete output from command python setup.py egg_info:
     failed to find headers for libxml2: update includes_dir

     ---------------------------------------- 
 Command "python setup.py egg_info" failed with error code 1 in
 /tmp/pip-install-72u9ke0y/libxml2-python3/

I tried the solutions provided in the following links but nothing works for me :我尝试了以下链接中提供的解决方案,但对我不起作用:

https://github.com/GoogleCloudPlatform/google-cloud-python/issues/3884 https://github.com/GoogleCloudPlatform/google-cloud-python/issues/3884

"pip install unroll": "python setup.py egg_info" failed with error code 1 “pip install unroll”:“python setup.py egg_info”失败,错误代码为 1

How to install libxml2 in virtualenv? 如何在 virtualenv 中安装 libxml2?

i work on fedora 27 os我在 Fedora 27 操作系统上工作

If I'm not mistaken, you would need the libxml2 development files.如果我没记错的话,您将需要 libxml2 开发文件。 Try running尝试跑步

yum install libxml2-devel

then run the pip install again然后再次运行 pip install

It's installed with lxml, in fact you probably want to use lxml instead of libxml2 because lxml is based on libxml2 is more pythonic:它与 lxml 一起安装,实际上你可能想使用 lxml 而不是 libxml2 因为 lxml 基于 libxml2 更pythonic:

sudo pip install lxml

libxml2 page says: libxml2 页面说:

Note that some of the Python purist dislike the default set of Python bindings, rather than complaining I suggest they have a look at lxml the more pythonic bindings for libxml2 and libxslt and check the mailing-list.请注意,一些 Python 纯粹主义者不喜欢默认的 Python 绑定集,而不是抱怨,我建议他们查看 lxml 的更多 Pythonic 绑定 libxml2 和 libxslt 并检查邮件列表。

lxml page says: lxml页面说:

The lxml XML toolkit is a Pythonic binding for the C libraries libxml2 and libxslt. lxml XML 工具包是 C 库 libxml2 和 libxslt 的 Pythonic 绑定。 It is unique in that it combines the speed and XML feature completeness of these libraries with the simplicity of a native Python API, mostly compatible but superior to the well-known ElementTree API.它的独特之处在于它将这些库的速度和 XML 功能完整性与本机 Python API 的简单性相结合,大部分兼容但优于众所周知的 ElementTree API。 The latest release works with all CPython versions from 2.6 to 3.6.最新版本适用于从 2.6 到 3.6 的所有 CPython 版本。 See the introduction for more information about background and goals of the lxml project.有关 lxml 项目的背景和目标的更多信息,请参阅介绍。 Some common questions are answered in the FAQ.常见问题解答中回答了一些常见问题。

I hit similar situation, my linux is Ubuntu on Windows 10 ( WSL - Windows Subsystem for Linux )我遇到了类似的情况,我的 linux 是 Windows 10 上的 Ubuntu( WSL - Windows Subsystem for Linux

What I did to solve the issue is:我为解决这个问题所做的是:

  1. Using apt, install: python3 python3-pip, libxml2 libxml2-dev.使用apt,安装:python3 python3-pip,libxml2 libxml2-dev。
me@WSL:~/$ sudo apt-get update
me@WSL:~/$ sudo apt install python3 python3-pip libxml2 libxml2-dev
  1. Using installed pip, install libxml2-python使用已安装的 pip,安装 libxml2-python
    me@WSL:~/$ pip3 install libxml2-python3
  1. done.完毕。 hope this notes help you.希望这篇笔记对你有帮助。

Yeah, I got the same error after trying to update the lmxl pip package.是的,我在尝试更新lmxl pip 包后遇到了同样的错误。 The problem is that lxml depends on both libmxl2 and libxslt development libraries.问题是lxml依赖于libmxl2libxslt开发库。 Therefore you need to make sure they are installed first.因此,您需要确保首先安装它们。

# pip3 show lxml
Name: lxml
Version: 4.2.5
Summary: Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API.
Home-page: http://lxml.de/
Author: lxml dev team
Author-email: lxml-dev@lxml.de
License: BSD
Location: /usr/lib/python3.6/site-packages
Requires:
Required-by: Scrapy, parsel, [etc etc]

So install the packages along the line with:因此,请使用以下命令安装软件包:

apt-get install libxml2-devel libxslt-devel

(And whatever they depend on in turn.) (以及他们依次依赖的任何东西。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM