mac 10.11安装lxml报错解决

由于接手新项目,项目里面需要安装lxml库

通过最简单的安装:1 从网上下lxml的tar文件,2 pip install lxml安装

开始了我痛苦的安装过程,在安装中报错:

#include "libxml/xmlversion.h"

 

^

 

1 error generated.

error: command '/usr/bin/clang' failed with exit status 1

开始了痛苦的往上查资料过程,百度看了不下于100个网页,通篇一律,就两个解决办法,都试用了一遍,还是报上面的错误。

唉,接着百度(木办法,为了养家糊口只能继续)

功夫不负有心人,终于被我找到了一个。最终参考文档:http://www.zhihu.com/question/30047496

操作步骤:

1 mac系统关闭sip

  具体关闭步骤参考:http://tieba.baidu.com/p/4209209897(这是个图文教程,很简单)

2 执行命令:xcode-select --install  确认安装了xcode commond line tool 也就是xcode的命令行工具

3 STATIC_DEPS=true sudo pip install lxml 最终安装

终于安装完成

测试:

Python 2.7.10 (default, Oct 23 2015, 18:05:06) 

[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import lxml

>>> lxml

<module 'lxml' from '/Library/Python/2.7/site-packages/lxml/__init__.pyc'>

>>> 

成功

猜你喜欢

转载自sls0919.iteye.com/blog/2276505