MAC OSX下用pip无法安装lxml的解决办法

来源:互联网 发布:python 实现卷积 编辑:程序博客网 时间:2024/05/19 02:45

一、问题现象

在安装pyspider时安装到lxml报错

   In file included from src/lxml/lxml.etree.c:323:    src/lxml/includes/etree_defs.h:14:10: fatal error: 'libxml/xmlversion.h' file not found    #include "libxml/xmlversion.h"             ^    1 error generated.    Compile failed: command 'clang' failed with exit status 1    cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitBMovjd.c -o tmp/xmlXPathInitBMovjd.o    /tmp/xmlXPathInitBMovjd.c:1:10: fatal error: 'libxml/xpath.h' file not found    #include "libxml/xpath.h"             ^    1 error generated.

二、解决之道

使用命令来设置编译的包含头文件

sudo C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2/libxml:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MaOSX10.11.sdk/usr/include pip install lxml


0 0
原创粉丝点击