Seeing this on macOS when installing a memcached client?

fatal error: 'libmemcached/memcached.h' file not found
#include <libmemcached/memcached.h>

Homebrew installs the headers under /usr/local (or /opt/homebrew on Apple Silicon), but some Python packages do not search that prefix automatically.

Quick fix

Point the build to the Homebrew prefix before installing:

# Intel macs
LIBMEMCACHED=/usr/local pip install <your-package>

# Apple Silicon
LIBMEMCACHED=/opt/homebrew pip install <your-package>

For Pipenv:

LIBMEMCACHED=/usr/local pipenv install <your-package>   # Intel
LIBMEMCACHED=/opt/homebrew pipenv install <your-package> # Apple Silicon

Why this works

Setting LIBMEMCACHED tells the build scripts where to find include/ and lib/ for libmemcached. Without it, the compiler cannot locate libmemcached/memcached.h on Monterey and later because the default search paths omit Homebrew prefixes.

If you still see errors, confirm libmemcached is installed:

brew install libmemcached