Search code examples
pythonxcodemacoslxml

GCC error installing lxml with pip on Mac OSX with Xcode


I'm a beginner trying to install lxml into an 2.7.3 installation of Python on my Mac.

I managed to install it into the Apple distribution but pip install lxml to that version returns the error:

error: command 'gcc-4.0' failed with exit status 1

Having scouted around on Stack Overflow the consensus is that there isn't Xcode, but it's definitely in place. What can I try?


Solution

  • The lxml package has to be compiled on your system (using llvm-gcc-X.X which is the Mac OS X version of gcc) so in order to complete the installation of lxml you must have XCode installed and also the XCode command line tools (for install instructions look here). Personally, I just finished installing Scrapy-0.14 and it compiled lxml in the same manner. Good Luck.