mac os用pip安装scrapy时报错#include "libxml/xmlversion.h" file not found

来源:互联网 发布:七周年荣耀赛车数据 编辑:程序博客网 时间:2024/06/05 20:55

安装一个python爬虫框架scrapy,pip安装时总是报如下错误:

lxml/src/lxml/includes/etree_defs.h:14:10: fatal error: 'libxml/xmlversion.h' file not found

    #include "libxml/xmlversion.h"

             ^

    1 error generated.

    error: command 'cc' failed with exit status 1

试了几次仍然不行,用作为'libxml/xmlversion.h' file not found关键词搜索

很快就找到来答案,记录一下。

C_INCLUDE_PATH要指定到XCode MacOSX SDK中libxml路径,一开始只看到:

C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2/libxml:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include
后来发现还要打上sudo和pip install才行

sudo C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2/libxml:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include pip install scrapy
1 0
原创粉丝点击