MAC OSX下用pip無法安裝lxml的解決辦法

一、問題現象

在安裝pyspider時安裝到lxml報錯

[plain] view plain copy
 print?
  1. In file included from src/lxml/lxml.etree.c:323:  
  2.  src/lxml/includes/etree_defs.h:14:10: fatal error: 'libxml/xmlversion.h' file not found  
  3.  #include "libxml/xmlversion.h"  
  4.           ^  
  5.  1 error generated.  
  6.  Compile failed: command 'clang' failed with exit status 1  
  7.  cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitBMovjd.c -o tmp/xmlXPathInitBMovjd.o  
  8.  /tmp/xmlXPathInitBMovjd.c:1:10: fatal error: 'libxml/xpath.h' file not found  
  9.  #include "libxml/xpath.h"  
  10.           ^  
  11.  1 error generated.  

二、解決之道

使用命令來設置編譯的包含頭文件

[plain] view plain copy
 print?
  1. 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 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章