使用 Visual Studio C++ 2010 Express 在 Windows x 86(32 位)上为 Python 3.4 安装 lxml

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23944465/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 03:44:04  来源:igfitidea点击:

Installing lxml for Python 3.4 on Windows x 86 (32 bit) with Visual Studio C++ 2010 Express

pythonc++visual-studio-2010lxml

提问by The Red Pea

Related

有关的

Related questions:

相关问题:

Related answers:

相关回答:

Related comments:

相关评论:

  • Building lxml for Python 2.7 on Windows
  • "@ziyuang This would mean you use Python 3.3 which uses Microsoft Visual Studio 2010. If that's the case then the answer is yes, you should install this version."
  • 在 Windows 上为 Python 2.7 构建 lxml
  • “@ziyuang 这意味着您使用的是使用 Microsoft Visual Studio 2010 的 Python 3.3。如果是这种情况,那么答案是肯定的,您应该安装此版本。”

Facts

事实

  • Windows x86 (32-bit)
  • Installed both Visual Studio C++ 2008 (from here) Express and Visual Studio C++ 2010 (from here)
  • Python 3.4.1 (apparently compiled with newer versionthan Visual Studio 2008)
  • I use pip (or pip3.4.exe; builtin to Python 3.4) to pip install lxml
  • distutils uses Visual Studio C++ 2010 Express to compile
  • Windows x86(32 位)
  • 安装了 Visual Studio C++ 2008(从这里)Express 和 Visual Studio C++ 2010(从这里
  • Python 3.4.1(显然是比 Visual Studio 2008更新的版本编译的)
  • 我使用 pip(或 pip3.4.exe;内置于 Python 3.4)来 pip install lxml
  • distutils 使用 Visual Studio C++ 2010 Express 编译

The last few lines of my error, logged by pip:

我的错误的最后几行,由 pip 记录:

cl : Command line warning D9025 : overriding '/W3' with '/w'

lxml.etree.c

C:\Users\NATHAN~1\AppData\Local\Temp\pip_build_nathanielanderson\lxml\src\lxml\includes\etree_defs.h(9) : fatal error C1083: Cannot open include file: 'libxml/xmlversion.h': No such file or directory

C:\Python34\lib\distutils\dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'

warnings.warn(msg)

error: command 'C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.exe' failed with exit status 2

cl:命令行警告 D9025:用“/w”覆盖“/W3”

lxml文件

C:\Users\NATHAN~1\AppData\Local\Temp\pip_build_nathanielanderson\lxml\src\lxml\includes\etree_defs.h(9):致命错误 C1083:无法打开包含文件:'libxml/xmlversion.h':否这样的文件或目录

C:\Python34\lib\distutils\dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'

警告。警告(味精)

错误:命令“C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.exe”失败,退出状态为 2

So I can't install from the .egg or by compiling...

所以我无法从 .egg 安装或通过编译...

Other Options

其他选项

I also can't find Windows installer (exe or msi or whatever) for this version of Python

我也找不到此版本 Python 的 Windows 安装程序(exe 或 msi 或其他)

Update 10/16/2019

2019 年 10 月 16 日更新

As commenter says, the executable links are no longer available

正如评论者所说,可执行链接不再可用

Looks like Chris doesprovide a direct exe here:

看起来 Chris确实在这里提供了一个直接的 exe:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml

http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml

Thanks, Chris! Any ideas why I cannot compile using pip?

谢谢,克里斯!任何想法为什么我不能使用 pip 编译?

采纳答案by Craig Yang

I also got this problem, but the workarounds provided above are not work for me as well.

我也遇到了这个问题,但上面提供的解决方法对我也不起作用。

Here is my system configuration:

这是我的系统配置:

  • Win7 64bit
  • python3.3
  • visual studio 2013
  • Win7 64位
  • 蟒蛇3.3
  • 视觉工作室 2013

I tried to use the method in the first link in the Related questions, but it's fail. This method is to create a system variable for vs2010 use, and the variable is actually copy from my original configuration in visual studio 2013.

我尝试在相关问题的第一个链接中使用该方法,但失败了。这个方法是创建一个vs2010使用的系统变量,这个变量实际上是从我在visual studio 2013的原始配置复制过来的。

However, the command line prompted error with "libxml/xmlversion.h" no suck file or directory

但是,命令行提示错误“libxml/xmlversion.h”没有suck文件或目录

Then I further searched it on the internet and got a method which works in my case.

然后我在互联网上进一步搜索它并获得了一种适用于我的情况的方法。

  1. downloading the precompiled lxml plugin

    Precompiled lxml 3.5: https://pypi.python.org/pypi/lxml/3.3.5#downloads

    if your system is 64bit, then you can get a unofficial version for x64 at here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml(this is what i use)

  2. installing with command in command line easy_install lxml-3.2.1.win32-py3.3.?exe

    Reference: https://pytools.codeplex.com/workitem/1520

  1. 下载预编译的 lxml 插件

    预编译的 lxml 3.5https: //pypi.python.org/pypi/lxml/3.3.5#downloads

    如果您的系统是 64 位,那么您可以在此处获得 x64 的非官方版本:http: //www.lfd.uci.edu/~gohlke/pythonlibs/#lxml(这是我使用的)

  2. 在命令行中使用命令安装easy_install lxml-3.2.1.win32-py3.3.?exe

    参考https: //pytools.codeplex.com/workitem/1520

回答by abarnert

The short version is: You need to have the C library libxml2(and also libxslt2) before you can build lxml.

简短的版本是:你需要有C库libxml2(也libxslt2),然后才能建立lxml



As the lxmlinstallation docssay:

正如lxml安装文档所说:

Unless you are using a static binary distribution (e.g. from a Windows binary installer), you need to install libxml2and libxslt, in particular:

  • libxml22.6.21 or later. It can be found here: http://xmlsoft.org/downloads.html

    • We recommend `libxml2 2.7.8 or a later version.
    • If you want to use XPath, do not use libxml22.6.27.
    • If you want to use the feed parser interface, especially when parsing from unicode strings, do not use libxml22.7.4 through 2.7.6.
  • libxslt1.1.15 or later. It can be found here: http://xmlsoft.org/XSLT/downloads.html

    • We recommend libxslt1.1.26 or later.

除非您使用的是静态二进制分发版(例如来自 Windows 二进制安装程序),否则您需要安装libxml2libxslt,特别是:

  • libxml22.6.21 或更高版本。可以在这里找到:http: //xmlsoft.org/downloads.html

    • 我们推荐`libxml2 2.7.8 或更高版本。
    • 如果要使用 XPath,请不要使用libxml22.6.27。
    • 如果要使用提要解析器接口,尤其是从 unicode 字符串解析时,请不要使用libxml22.7.4 到 2.7.6。
  • libxslt1.1.15 或更高版本。可以在这里找到:http: //xmlsoft.org/XSLT/downloads.html

    • 我们推荐libxslt1.1.26 或更高版本。

The build from source docssimilarly start off with:

来自源文档构建同样从以下开始:

To build lxml from source, you need libxml2 and libxslt properly installed, including the header files.

要从源代码构建 lxml,您需要正确安装 libxml2 和 libxslt,包括头文件。



Windows (unlike most other platforms) doesn't come with these libraries. You don't mention anything in your "Facts" about having them.

Windows(与大多数其他平台不同)没有这些库。您没有在“事实”中提及有关拥有它们的任何内容。



And the error message that you showed is:

您显示的错误消息是:

C:\Users\NATHAN~1\AppData\Local\Temp\pip_build_nathanielanderson\lxml\src\lxml\includes\etree_defs.h(9) : 
fatal error C1083: Cannot open include file: 'libxml/xmlversion.h': 
No such file or directory

That 'libxml/xmlversion.h'that it can't find is part of libxml2.

'libxml/xmlversion.h'是它无法找到是的一部分libxml2



It's also worth noting that the same installation docs explicitly say:

还值得注意的是,相同的安装文档明确指出:

consider using the binary builds from PyPI or the unofficial Windows binaries that Christoph Gohlke generously provides.

考虑使用来自 PyPI 的二进制版本或 Christoph Gohlke 慷慨提供的非官方 Windows 二进制文件。

So, the fact that you thought Christoph Gohlke didn't provide binaries for lxmlimplies that you hadn't found these docs.

因此,您认为 Christoph Gohlke 没有提供二进制文件的事实lxml意味着您没有找到这些文档。



So, it's possible that you did install libxml2, but not in a way that lxml2's setup script can find it. But all the evidence implies it's a lot more likely that you just don't have it.

因此,您可能确实安装了libxml2,但不是lxml2安装脚本可以找到的方式。但所有的证据都表明,你根本没有它的可能性要大得多。

回答by HVT7

If you are using python 3.4 this is the download link :

如果您使用的是 python 3.4,这是下载链接:

Download Here

在这里下载

If you have any other configuration find it HEREaccording to your need. ;-)

如果您有任何其他配置,请根据需要在此处找到它。;-)