ImportError: No module named zlib on macOS Catalina

November 22, 2019

A few times now, I've had to get around an issue that happens on macOS Catalina where you try to run a Python script and it fails with an import error:

ImportError: No module named zlib

The stacktrace will differ based on what was trying to import zlib, but the fix for me (on the most recent Catalina builds) was to reinstall python2 or python3 via brew. As some others have noted, it's important to xcode-select --install first, if you haven't.

If the script is Python 2:

brew reinstall python2

If the script is Python 3:

brew reinstall python3
Tweet This
Get New Posts Via Email
Picture of me with a corgi

Noah Gilmore

I'm Noah, a software developer based in the San Francisco Bay Area. I focus mainly on full stack web and iOS development

  • 💻 I co-founded Replo, a no-code platform for e-commmerce
  • ✍️ You can read technical posts on my blog
  • 📱 I wrote an app which lets you create transparent app icons called Transparent App Icons
  • 🧩 I made a puzzle game for iPhone and iPad called Trestle
  • 🎨 I wrote a CoreImage filter utility app for iOS developers called CIFilter.io
  • 👋 Please feel free to reach out on Twitter / 𝕏