sssilver
sssilver

Reputation: 2869

lxml won't install under pypy using easy_install

When doing:

$ sudo pypy -m easy_install lxml

The response is:

Searching for lxml

[...snip...]

ERROR: /bin/sh: 1: xslt-config: not found

** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt 
/usr/lib/pypy/lib-python/2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
  warnings.warn(msg)
warning: no files found matching '*.txt' under directory 'src/lxml/tests'
src/lxml/lxml.etree.c:8:22: fatal error: pyconfig.h: No such file or directory
compilation terminated.
error: Setup script exited with error: command 'cc' failed with exit status 1

At the same time, sudo pip install lxml works fine.

What's going on?

Thanks.

Upvotes: 3

Views: 5970

Answers (4)

Gill Bates
Gill Bates

Reputation: 15217

I've handled this problem by installed Ubuntu package pypy-dev.

Upvotes: 2

Richard Gomes
Richard Gomes

Reputation: 6094

I've stumbled with this trouble a couple of times.

Short answer

Python2: $ python2.7 setup.py clean build --with-cython install
Python3: $ pip-3.3 install lxml

Long answer

The hypothesis is that pip install lxml should work in every environment, regardless if you are using Python2 or Python3.

There's also Cython to be considered: You will certainly enjoy lxml compiled with Cython due to relevant performance gains.

For reasons unknown to me, the compilation on Python2 does not find Cython. To be more precise and absolutely explicit about this matter, both commands below DO NOT employ Cython:

# DO NOT use these commands. I repeat: DO NOT use these commands.
$ pip-2.7 install lxml
$ easy_install-2.7 install lxml

So, when using Python2 you have only one alternative, as far as I know, which is: compile from sources, Luke!

# install build environment and dependencies
$ kernel_release=$( uname -r )
$ sudo apt-get install linux-headers-${kernel_release} build-essential -y
$ sudo apt-get install libxml2-dev libxslt1-dev -y

# Download from github and compile from sources
$ git clone --branch lxml-3.2.4 https://github.com/lxml/lxml
$ python2.7 setup.py clean build --with-cython install

Upvotes: 2

hughes
hughes

Reputation: 5713

sudo apt-get install python-dev fixed it for me on ubuntu 13.04

Upvotes: 7

Nikhil Rupanawar
Nikhil Rupanawar

Reputation: 4191

$yum install python-lxml or apt-get install python-lxml this solved mine.

Upvotes: 4

Related Questions