how to install lxml python module on mac os x 10.5(leopard)

lxml依赖[url=http://xmlsoft.org/]xmlsoft[/url]的两个库libxml2和libxslt,要首先正确安装,可能还要安装cython,因为有些实现用到了

最开始用easy_install lxml失败,只好从源码编译开始,参考[url=http://codespeak.net/lxml/build.html#building-lxml-on-macos-x]这里[/url]
下载lxml,解压,执行。(Mac下成功编译的关键是要指定static-deps参数
python setup.py build --static-deps --libxml2-version=2.7.3 --libxslt-version=1.1.24 

setup.py程序会自动下载指定版本libxml2和libxslt,然后在build的临时目录下编译


如果编译安装出现下列问题,
.....
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
..........
error: Setup script exited with error: command 'gcc' failed with exit status 1

可能是Mac OS X Leopard下gcc版本的问题,我的gcc早些时候更新到gcc4.2.1,编译前将其指定为gcc4.0就好了:
export CC="gcc-4.0"
export CXX="g++-4.0"



BTW: ubuntu 9.04
sudo apt-get install libxml2 libxml2-dev
sudo apt-get install libxslt-dev

sudo easy_install lxml
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值