I previously stumbled in the “SpatiaLite requires SQLite to be configured to allow extension loading.” error stemming from AttributeError: 'sqlite3.Connection' object has no attribute 'enable_load_extension'
exception when trying to run Django with Spatialite. The root issue is that macOS Python installations hasn’t been built with the loadable SQLite extensions enabled. Not sure what changed with macOS Sequoia but the previous installation method didn’t work anymore.
I got Claude to help me debug the issue and after quite a many attempts this is the fixed installation method that fixed the issue for me:
export SQLITE_PREFIX=$(brew --prefix sqlite)
export CPPFLAGS="${CPPFLAGS} -DSQLITE_ENABLE_LOAD_EXTENSION=1"
export CFLAGS="${CFLAGS} -DSQLITE_ENABLE_LOAD_EXTENSION=1"
PYTHON_CONFIGURE_OPTS="--enable-loadable-sqlite-extensions" \
LDFLAGS="-L${SQLITE_PREFIX}/lib" \
CPPFLAGS="-I${SQLITE_PREFIX}/include" \
pyenv install -v 3.13.1