5

I'm making a bot for a wiki I'm setting up, and for it I need requests and lxml. However, when I do pip install lxml it gives me:

Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-_dKbZg/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-qFSiy8-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-build-_dKbZg/lxml
Storing debug log for failure in /root/.pip/pip.log

and pip.log mentions something about having to have "the developer builds of libxml2 and libxslt" installed, but I don't know how to get those. Some help?

Steve Robillard
  • 34,988
  • 18
  • 106
  • 110
Demosthenes
  • 51
  • 1
  • 1
  • 2

2 Answers2

10

The error you are reporting is the result of missing requirements. Per the lxml install instructions, the simplest method of installing it is:

sudo apt-get install python3-lxml python-lxml

You may need to install a few required packages first. You can do this with the following command:

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

Once the requirements are installed you can retry the pip install if that is your preferred method of installing packages.

Steve Robillard
  • 34,988
  • 18
  • 106
  • 110
0

Steve has right solution. After doing what he suggested I got lxml on Raspberry pi 3 B+

pi@raspberrypi:~ $ pip install lxml --user
Collecting lxml
  Using cached https://files.pythonhosted.org/packages/54/a6/43be8cf1cc23e3fa208cab04ba2f9c3b7af0233aab32af6b5089122b44cd/lxml-4.2.3.tar.gz
Building wheels for collected packages: lxml
  Running setup.py bdist_wheel for lxml ... done
Stored in directory: /home/pi/.cache/pip/wheels/24/bb/48/083d2f101c447e302e7d9593b1a4432f5934141c9bc77d8275
Successfully built lxml
Installing collected packages: lxml
Successfully installed lxml-4.2.3
Bex
  • 2,929
  • 3
  • 26
  • 34