How to install lxml in PyCharm on Mac OS Catalina

imac mac os catalina xxl

I still run Mac OS Catalina on my iMac (yes, I know, it sounds kind of vintage when everyone is moving to macOS Ventura, released in late October 2022). 

Everything is fine performance-wise but once in a while I run into some configuration issues. 

Recently, in order to use the Python Google Ads API, I needed to install the lxml package in PyCharm and I kept on getting an error… it was impossible to fix it via the Terminal!

No way to install the lxml package, apparently because libxml2 and  libxslt were missing… 

I had to install those libraries, using Homebrew

The problem was that I could not complete the Homebrew installation via the Terminal. It was stuck on the “Finding software…” modal while trying to download the Command Line Developer Tools for Xcode. 

Fortunately I found a post on Reddit which shared a link to a life-saving Apple repository offering archives of legacy versions of those Command Line Developer Tools. 

command line tools xcode 12.4
command line tools for xcode 12.4

I had to scroll quite a bit to find the CLT release corresponding to my old version of Xcode (12.4). 

I downloaded the .dmg (430MB), installed the Command Line Tools, then installed Homebrew via the Terminal, using this command. 

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

It all went pretty smoothly. 
I used Brew to install both missing libraries, libxml2 and libxslt

brew install libxml2
brew install libxslt

I then restarted PyCharm and installed the lxml package. 

All set! Working like a charm. Ready to code.

🚀 Subscribe to my weekly newsletter packed with tips & tricks around AI, SEO, coding and smart automations

☕️ If you found this piece helpful, you can buy me coffee