I have recently upgraded to OS X Yosemite. And somehow my lxml installation broke. When I tried to do pip install lxml
, I was getting an error: ‘libxml/xmlversion.h’ file not found. The error message is obvious. While trying to compile lxml, it can’t find the libxml header files. What was not very obvious to me is how to fix this. I am using Homebrew. I upgraded both libxml2 and libxslt. Didn’t work. After quite some googling and checking out some stack overflow answers, I found out my mistake. By default, brew wouldn’t link the libxml and libxslt to avoid conflicts. So I have to force them. In short, this is what I needed to do:
1 2 |
brew link libxml2 --force brew link libxslt --force |
Of course, if you didn’t have them installed before, you need to install them first:
1 2 |
brew install libxml2 brew install libxslt |
If it doesn’t work even after force linking, you may want to first unlink previous versions.
1 2 |
brew unlink libxml2 brew unlink libxslt |
Then I tried to install lxml from pip and it worked like a charm! 🙂