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

3

11

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."

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 version than 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

The last few lines of my error, logged by 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

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

Other Options

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

Update 10/16/2019

As commenter says, the executable links are no longer available

Looks like Chris does provide a direct exe here:

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

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

Bookkeeper answered 29/5, 2014 at 23:6 Comment(3)
"Looks like Chris does provide a direct exe here: (link)" Where?? I don't see any exe for LXML, only wheel files. Was it removed?Mano
Hi @Calydon, you're right... I don't know what to suggest. The old executable links don't work. Maybe installing from the whl files is straightforward and can be done instead of exe. Otherwise try this site (thanks to accepted answer)Bookkeeper
In the end I was able to get the 3.8 whl to work (as you'd expect with Python3.8). Not sure if it was there when I first looked. These types of technical hangups are the bane of inexperienced programmers. Python should 'just work'.Mano
S
9

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

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.

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

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

Staid answered 10/11, 2014 at 8:50 Comment(3)
Yes I needed Gohlke, per my question. Sounds like you needed Gohlke also, per your specs:64bit. Did you need Gohlke? Which version of lxml would you recommend? pypi.python.org/pypi/lxml lists a few; why does your answer mention 3.3.5? Finally, why use easy_install on the executable, can't you just open the executable? Thanks.Bookkeeper
1. yes, as i said i use lxml 3.4.1 Gohlke version which is a unofficial version 2. actually, i am a newcomer who just start to learn this plugin. sorry for that 3. ver 3.3.5 is what i looked for at first, but there is no any available component for python 3.3 4. i think you can, i have tried to execute it after reading your question... it can detect successfully the python3.3 installed in my system in the prepossessing announcement. but i didn't really make the installation process since i already installed it. Hope this helps!Staid
Great! Download precompiled lxml from lfd.uci.edu/~gohlke/pythonlibs/#lxml works for me.Biological
M
6

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

Download Here

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

Mossman answered 10/12, 2014 at 11:0 Comment(2)
tried lxml-3.5.0-cp34-none-win32.whl on windows 7 from the second link. works like a charm.Upholster
Using the above link to Gohlke's site, I could NOT install the win32 version, but was successful (on my 64-bit Intel-based Windows system) with the win_amd64 version. Download the whl file to c:\Python34\Scripts, then run c:\Python34\Scripts>pip install "lxml-3.5.0-cp34-none-win_amd64.whl" Results: Unpacking c:\python34\scripts\lxml-3.5.0-cp34-none-win_amd64.whl Installing collected packages: lxml Successfully installed lxml Cleaning up...Tyler
H
3

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


As the lxml installation docs say:

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

  • libxml2 2.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 libxml2 2.6.27.
    • If you want to use the feed parser interface, especially when parsing from unicode strings, do not use libxml2 2.7.4 through 2.7.6.
  • libxslt 1.1.15 or later. It can be found here: http://xmlsoft.org/XSLT/downloads.html

    • We recommend libxslt 1.1.26 or later.

The build from source docs similarly start off with:

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


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


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.


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.

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


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.

Hepcat answered 5/9, 2014 at 0:7 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.