7

This is the command I used to install lxml:

sudo pip install lxml

And I got the following message in the Cleaning Up stage:

Cleaning up...
Command /usr/bin/python -c "import setuptools,     tokenize;__file__='/private/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-rUFjFN-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/tmp/pip_build_root/lxml
Storing debug log for failure in /Users/georgejor/Library/Logs/pip.log

After that, I got:

ImportError: No module named lxml

Please help. Thanks!

The following output is from pip.log:

----------------------------------------
Cleaning up...
  Removing temporary dir /private/tmp/pip_build_root...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-rUFjFN-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/tmp/pip_build_root/lxml
Exception information:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/Library/Python/2.7/site-packages/pip/req.py", line 1435, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/pip/req.py", line 706, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/Library/Python/2.7/site-packages/pip/util.py", line 697, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-rUFjFN-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/tmp/pip_build_root/lxml
Ian Stapleton Cordasco
  • 26,944
  • 4
  • 67
  • 72
George Jor
  • 501
  • 1
  • 7
  • 18
  • This means that `lxml` was not properly installed. Do this `cat /Users/georgejor/Library/Logs/pip.log` and show that to us in the question. – Games Brainiac Oct 10 '14 at 03:17
  • Ok i've just added. Hope it can help. – George Jor Oct 10 '14 at 03:21
  • It looks like you don't have setuptools installed. Install setuptools using `pip install setuptools` – Games Brainiac Oct 10 '14 at 03:21
  • When I run pip install setuptools, it shows: Requirement already satisfied (use --upgrade to upgrade): setuptools in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python Cleaning up... – George Jor Oct 10 '14 at 03:23
  • and I use pip to install lxml, same message – George Jor Oct 10 '14 at 03:24
  • When you ran `pip install lxml`, did you get any error messages? – WKPlus Oct 10 '14 at 03:25
  • No, but the red color message after Cleaning Up... – George Jor Oct 10 '14 at 03:29
  • Okay, what system are you on? – Games Brainiac Oct 10 '14 at 03:31
  • OSX 10.10 with python 2.7 and pip 1.5.6 – George Jor Oct 10 '14 at 03:36
  • The log segment given isn't helpful. We need to know why the compile failed, not anything about the attempted cleanup _after_ the compile. If I were to place money on the issue, I'd put mine on @ragingSloth's answer (which I'm only not upvoting because I have serious issues with using SO as a forum for installation-support questions rather than programming questions). – Charles Duffy Oct 10 '14 at 23:31
  • I had a similar problem but installing llvmlite, after many hours of debugging my friend found out that it was using the wrong version of LLVM. – gota Apr 23 '15 at 16:53

3 Answers3

12

Just install these stuff :

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

Then try again :

pip install lxml
Kiru Prem
  • 121
  • 3
  • this worked for me. Although blindly copying various programs to install I have no idea about is known not to be a good idea but it did work :-) – Martin Nov 02 '15 at 00:19
1

lxml has C depenedencies, often I run into issues when I'm missing libxslt or libxml2. Are you sure that all non python dependencies are installed?

ragingSloth
  • 1,094
  • 8
  • 22
0

Here is a similar question.

Error installing Pillow (and PIL)

Are you using a MacOS? Maybe you can try to update the commandline tools and try 'brew' tool. If not, you can try to install pip and easy_intall tools again, and update it.

https://pip.pypa.io/en/latest/installing.html

Community
  • 1
  • 1