while running a python script, I got this error
from lxml import etree
ImportError: No module named lxml
now I tried to install lxml
sudo easy_install lmxl
but it gives me the following error
Building lxml version 2.3.beta1.
NOTE: Trying to build without Cython, pre-generated 'src/lxml/lxml.etree.c' needs to be available.
ERROR: /bin/sh: xslt-config: not found
** make sure the development packages of libxml2 and libxslt are installed **
Using build configuration of libxslt
src/lxml/lxml.etree.c:4: fatal error: Python.h: No such file or directory
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1
If you're running python3, you'll have to do:
pip3 install lxml
Just do:
For Python 2 (e.g., required by Inkscape):
If you are planning to install from source, then albertov's answer will help. But unless there is a reason, don't, just install it from the repository.
You need to install Python's header files (python-dev package in debian/ubuntu) to compile lxml. As well as libxml2, libxslt, libxml2-dev, and libxslt-dev:
I solved it upgrading the lxml version with:
For RHEL/CentOS, run "python --version" command to find out Python version. E.g. below:
Now run "sudo yum search lxml" to find out python*-lxml package.
Now you can choose package as per your Python version and run command like below: