Installing lxml module in python

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

Missing lxml module in python?

I want o use Python-docx library to process word files. A docx.py references lxml, as i assume from from lxml import etree When i start the script, i get error: No module named lxml Is this a stand

Error installing python module lxml on osx mavericks

Here is my python env: note that numpy is working 13:41:44/shared:5 $python Python 2.7.5 (default, Aug 25 2013, 00:04:04) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type help,

Problems Installing lxml with python/django

I am trying to use lxml in one of my projects in django, but I am having trouble installing the lxml module. I am using Ubuntu 10.04. I have looked on the web for suitable tutorials on how to install

Installing lxml with python on a mac

First, I installed lxml without using pip (Python 2.7.2 on Mac OS 10.6.8). Then, I read this post and I installed it again using pip (sudo pip install lxml). I still had a problem: I can import lxml (

installing lxml on the hosting server for python

I had been using mikemaccana-python-docx module for reading from and writing to doc files in python. Now I had to move this feature to hosting server. Can any body suggest a way to install lxml on the

Issues with installing lxml with Python3 (MacOS)

Been trying to install lxml with my Python 3 installation on a Mountain Lion OSX machine, following the instructions here: http://lxml.de/build.html#building-lxml-on-macos-x I get the following error

installing Sybase module for python

I’m having some trouble installing the Sybase python module. I’ve downloaded the zip file, unzipped and run python setup.py install in that directory. However, I get this error; Directory I:/Sybase/sq

Problems installing lxml on a Mac, it installs but module not found

The code from lxml import etree produces the error ImportError: No module named lxml Running sudo easy_install lxml results in lxml 2.2.7 is already the active version in easy-install.pth Removing

No module named lxml from python using php

I’m having a problem in using python’s plugin lxml .. When I execute python python.py it works in the server but when I use php system(python python.py) it goes blank. PYTHON CODE: from lxml import

Installing python module

I’m new to python and is trying to install the pyimage module. http://code.google.com/p/pyimage/ I’m on Windows, and have downloaded and installed 2.6 and 3.1. I downloaded pyimage, and used cmd and c

Answers

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:

apt-get install python-dev libxml2 libxml2-dev libxslt-dev

Just do:

sudo apt-get install python-lxml

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.

I was having the same problem and had success using the binaries at: http://www.lfd.uci.edu/~gohlke/pythonlibs/ (if you’re on Windows…)

I solved it upgrading the lxml version with:

pip install –upgrade lxml

If you’re running python3, you’ll have to do:

pip3 install lxml

For RHEL/CentOS, run “python –version” command to find out Python version. E.g. below:

$ python --version 
  Python 2.7.12

Now run “sudo yum search lxml” to find out python*-lxml package.

$ sudo yum search lxml
Failed to set locale, defaulting to C
Loaded plugins: priorities, update-motd, upgrade-helper
1014 packages excluded due to repository priority protections
============================================================================================================= N/S matched: lxml =============================================================================================================
python26-lxml-docs.noarch : Documentation for python-lxml
python27-lxml-docs.noarch : Documentation for python-lxml
python26-lxml.x86_64 : ElementTree-like Python bindings for libxml2 and libxslt
python27-lxml.x86_64 : ElementTree-like Python bindings for libxml2 and libxslt

Now you can choose package as per your Python version and run command like below:

$ sudo yum install python27-lxml.x86_64