1

I am trying to install this library on Mac OSx 10.11 using this command:

sudo -H pip install lxml

While I keep getting this message:

#include "libxml/xpath.h"
         ^
1 error generated.
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
Perhaps try: xcode-select --install
*********************************************************************************
error: command 'cc' failed with exit status 1

Yet I am pretty sure that libxml2 is installed here:

/usr/local/Cellar/libxml2/2.9.2/include/libxml2

I used brew to install this package. There shouldn't be any problem. How should I fix it?

SaidbakR
  • 12,574
  • 18
  • 96
  • 182
alvinzoo
  • 453
  • 2
  • 7
  • 17
  • Possible duplicate of [Getting "Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?" when installing lxml through pip](https://stackoverflow.com/questions/33785755/getting-could-not-find-function-xmlcheckversion-in-library-libxml2-is-libxml2) – Stevoisiak Feb 13 '18 at 15:38

1 Answers1

3

Homebrew doesn't link libxml and libxslt to avoid conflicts. You need to --force them.

brew link libxml2 --force
brew link libxslt --force

I faced this problem when I upgraded to latest OS X. I wrote a blog post on it detailing the issue.

masnun
  • 10,986
  • 4
  • 37
  • 48