Search code examples
pythonxcodemacosscrapylxml

Cannot install Lxml on Mac OS X 10.9


I want to install Lxml so I can then install Scrapy.

When I updated my Mac today it wouldn't let me reinstall lxml, I get the following error:

In file included from src/lxml/lxml.etree.c:314:
/private/tmp/pip_build_root/lxml/src/lxml/includes/etree_defs.h:9:10: fatal error: 'libxml/xmlversion.h' file not found
#include "libxml/xmlversion.h"
         ^
1 error generated.
error: command 'cc' failed with exit status 1

I have tried using brew to install libxml2 and libxslt, both installed fine but I still cannot install lxml.

Last time I was installing I needed to enable the developer tools on Xcode but since it's updated to Xcode 5 it doesn't give me that option anymore.

Does anyone know what I need to do?


Solution

  • You should install or upgrade the command line tool for Xcode. Try this in a terminal:

    xcode-select --install
    

    If Xcode Command Line Tools are already installed, but you're still not able to install lxml, then reset xcode-select by following the command:

    sudo xcode-select --reset
    

    This will reset the path to the Xcode Command Line Tools directory and may resolve the issue.

    After you've installed or updated Xcode Command Line Tools, Hopefully, this will resolve the issue and allow you to install the "lxml" package.