Thursday, January 8, 2015

Building lxml on Centos 6

Building lxml on Centos 6



Background

I seem to find lots of issues with building lxml. I find it annoying to search and not find a good answer. Then there are so many ways to install python modules : tar file/make, easy_install, pip, etc, rpms. I found that my favorite flavor to install for now is pip.


Installation

If you performed a previous installation please rm -rf /tmp/pip-build-[username]. This will save you alot of grief.

 
Install epel repo
rpm -Uhv http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm


Install required rpm

yum install gcc python-pip python-devel libxml2-devel libxslt-devel zlib-devel -y

Run pip

pip install lxml

Check
$ pip list
distribute (0.6.10)
iniparse (0.3.1)
lxml (3.4.1)
pycurl (7.19.0)
pygpgme (0.1)
urlgrabber (3.9.1)
yum-metadata-parser (1.1.2)


$ python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
>>>