Skip to content
Advertisement

Problems installing lxml on M1 mac

So, I’m having the classic trouble install lxml.

Initially I was just pip installing, but when I tried to free up memory using Element.clear() I was getting the following error:

JavaScript

I thought this must be because lxml is using the system’s libxml2 which is probably out of date.

So I used homebrew to install libxml2 and libxlt, and I force linked them both.

I then tried to install using the following command:

JavaScript

..but then when I tried to import etree I would get this error:

JavaScript

So then I thought let’s make 100% sure that it’s using the right versions of libxml2 using CFLAGS and got the following result:

JavaScript

Do I need to do something special to build lxml on an m1 mac?

Advertisement

Answer

It turned out that installing lxml with a simple pip install was working fine.

The reason for my malloc error was the fact that I was trying to clear the element before the end tag had been seen. Turns out this isn’t possible and you need to wait for the end tag even if you already know you aren’t interested in the element.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement