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参数
setup.py程序会自动下载指定版本libxml2和libxslt,然后在build的临时目录下编译
如果编译安装出现下列问题,
可能是Mac OS X Leopard下gcc版本的问题,我的gcc早些时候更新到gcc4.2.1,编译前将其指定为gcc4.0就好了:
BTW: ubuntu 9.04
sudo apt-get install libxml2 libxml2-dev
sudo apt-get install libxslt-dev
sudo easy_install lxml
最开始用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