Homebrew install libxml2 with python modules

First, you cannot install libxml2 because you already successfully installed it, so you will first need to uninstall it.

brew uninstall libxml2

Next you will need to edit the brew formula - which is simple enough to do --

type brew edit libxml2 and change the line

system "./configure", "--prefix=#{prefix}", "--without-python"

to this:

system "./configure", "--prefix=#{prefix}", "--with-python"

This does not fix the problem with the brew formula, but it does force the flag "--with-python", so the next time you type brew install libxml2 it will install the python libraries.

If you need to reset the formula (undo your changes), simply type brew update


What worked for was installing libxml2 with --with-python in brew command

brew install --with-python libxml2

This worked for me. First unlink/uninstall if done previously:

brew unlink libxml2
brew unlink libxslt
brew uninstall libxml2
brew uninstall libxslt

Then

brew install --framework python
brew install --with-python libxml2
brew install --with-python libxslt
brew link libxml2 --force
brew link libxslt --force

Voila!