Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot install lxml on windows, fatal error C1083: Cannot open include file: 'libxml/xmlversion.h'

Python noob, please bear with me. I used python installer for v3.5.1 from www.python.org. My intent was to use Scrapy to run some scripts.

pip install scrapy failed, as did easy_install scrapy and others. I traced the error to a faulty install of lxml. Here is the error log. I've even tried easy_installing libxml2, I'm not sure how to proceed.

Building lxml version 3.5.0.
Building without Cython.
ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"
** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt
cl : Command line warning D9025 : overriding '/W3' with '/w'
lxml.etree.c
src\lxml\includes\etree_defs.h(14): fatal error C1083: Cannot open include file: 'libxml/xmlversion.h': No such file or directory
Compile failed: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2
xmlXPathInitck3f6zpk.c
C:\Users\Rohan\AppData\Local\Temp\easy_install-47utdost\lxml-3.5.0\temp\xmlXPathInitck3f6zpk.c(1): fatal error C1083: Cannot open include file: 'libxml/xpath.h': No such file or directory
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: Setup script exited with error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2
like image 494
Freakishly Avatar asked Dec 30 '15 19:12

Freakishly


2 Answers

I had the same problem, albeit using WinPython 64bit 2.7.3.1.

I solved it using the precompiled installer which can be found here: https://pypi.python.org/pypi/lxml/3.3.3#downloads

Directly installing the package by running the .exe failed, because the installer could not find my python installation (altough it is registered). However, I then successfully used the WinPython Control Panel to install the package!

edit: before that, I tried various things which I found on stackoverflow, including installing some Visual C++ (Python) compilers but none of that worked.

like image 187
phase-contrast Avatar answered Nov 16 '22 20:11

phase-contrast


I had the same problem using Python 64bit 2.7.11 on Windows 10.

After I tried installing scrapy using pip many times, I had success as follow:

  1. First I installed precompiled package lxml v3.6.0 from .exe file. It can be found here https://pypi.python.org/pypi/lxml/3.6.0.

  2. Finally, I ran pip install scrapy again and installation ended successful.

Happy hacking !!!

like image 2
Randy Mujica Avatar answered Nov 16 '22 19:11

Randy Mujica