如何添加缺失的C库以在cygwin中安装lxml?

时间:2019-03-19 09:43:51

标签: python-2.7 gcc pip cygwin lxml

我正在将cygwin用于python。我无法安装lxml,因为它显示了一些缺少库的错误。

 creating tmp
 cc -I/usr/include/libxml2 -c /tmp/xmlXPathInit94yfjj.c -o 
 tmp/xmlXPathInit94yfjj.o
 /tmp/xmlXPathInit94yfjj.c:1:10: fatal error: **libxml/xpath.h: No such file 
 or directory**
 #include "libxml/xpath.h"
        ^~~~~~~~~~~~~~~~
 compilation terminated.


 Could not find function xmlCheckVersion in library libxml2. Is libxml2  
 installed?

 ***error: command 'gcc' failed with exit status 1***


 Failed building wheel for lxml
 Running setup.py clean for lxml
 Failed to build lxml
 Installing collected packages: lxml
 Running setup.py install for lxml ... error
 Complete output from command 
 /cygdrive/c/Users/1419104/Torutils/env/bin/python -u -c "import setuptools, 
 tokenize;__file__='/tmp/pip-install-
 3aL8Ib/lxml/setup.py';f=getattr(tokenize, 'open', open)
 (__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, 
 __file__, 'exec'))" install --record /tmp/pip-record-driSho/install-
 record.txt --single-version-externally-managed --compile --install-headers 
 /cygdrive/c/Users/1419104/Torutils/env/include/site/python2.7/lxml:
 Building lxml version 4.3.2.

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

您缺少libxml2的开发软件包

 $ cygcheck -p libxml/xpath.h
Found 7 matches for libxml/xpath.h
libxml2-devel-2.9.3-1 - libxml2-devel: GNOME XML library (development) (installed binaries and support files)
libxml2-devel-2.9.4-1 - libxml2-devel: GNOME XML library (development) (installed binaries and support files)
libxml2-devel-2.9.4-2 - libxml2-devel: GNOME XML library (development)
...

安装libxml2-devel软件包的正确方法是使用cygwin安装程序