安装一个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
本文详细介绍了在安装Python爬虫框架Scrapy时遇到libxml/xmlversion.h文件未找到的错误,并提供了通过指定C_INCLUDE_PATH路径来解决问题的方法。包括在XCode MacOSX SDK中的正确配置步骤和使用sudo权限执行pip install Scrapy。
2124

被折叠的 条评论
为什么被折叠?



