How to (finally) Install PyCURL on MacOS

In this guide, I'm showing you a complete solution on how to install pycurl on macOS. Yes, that includes solving those pesky errors on mac.

How to (finally) Install PyCURL on MacOS
Photo by Chris Ried / Unsplash

Every few months, I find myself installing pycurl as part of one project or another on my Macbook and experiencing installation failures. I used to spend a lot of time googling what was wrong and realizing how to fix it. And now, finally, I found the source of all those Stack Overflow half-answers: Brew.

How to install Brew on Mac

Brew is a package manager for MacOS computers. According to brew's official website, you need to run this command to install brew:

/bin/bash -c "$(curl -fsSL"

How to Install Pycurl on MacOS

Step 1: open a terminal and run brew info openssl

If OpenSSL is not installed, start with brew install openssl before retrying the above command.

You should see this output in your terminal.

Step 2: export env variables as suggested.

Export the suggested compilations environment variables in the same terminal where you attempt to install pycurl (works in your poetry shell, too, for those who use that package manager). This includes the update to your PATH and the compiler flags.

The reason is that the LDFLAGS and CPPFLAGS env variables are not automatically set on the system because macOS automatically provides LibreSSL. And in addition, the PATH doesn’t include it either in favor of LibreSSL. Hence, pycurl fails to find OpenSSL when trying to install it.

And that's it! Your pycurl installation should work as expected.


Installing pycurl on mac requires some info from brew about your OpenSSL installation. Once you output that information and export it as env variables, you should be able to install pycurl with no problems on your macOS.

Check out other Python tutorials right here.

Let me know in the comments below if you have any other questions!