BUG building the documentation

### Describe the bug

When building the documentation, I get an error.

### Steps/Code to Reproduce

```bash
cd scikit-learn/doc
make
```

### Expected Results

Successful built
```
Build finished. The HTML pages are in $_build/html/stable.
```

### Actual Results

```
...
copying images... [100%] _build/plot_directive/visualizations-2.png
dumping search index in English (code: en)... done
dumping object inventory... done
copying binder requirements...
copying binder notebooks...[100%] auto_examples
Sphinx-Gallery gallery_conf["plot_gallery"] was False, so no examples were executed.
embedding documentation hyperlinks...

Traceback (most recent call last):
  File "/Users/lorentzen/github/python3_sklearn/lib/python3.12/site-packages/sphinx/events.py", line 97, in emit
    results.append(listener.handler(self.app, *args))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lorentzen/github/python3_sklearn/lib/python3.12/site-packages/sphinx_gallery/docs_resolv.py", line 488, in embed_code_links
    _embed_code_links(app, gallery_conf, gallery_dir)
  File "/Users/lorentzen/github/python3_sklearn/lib/python3.12/site-packages/sphinx_gallery/docs_resolv.py", line 323, in _embed_code_links
    doc_resolvers[this_module] = SphinxDocLinkResolver(
                                 ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lorentzen/github/python3_sklearn/lib/python3.12/site-packages/sphinx_gallery/docs_resolv.py", line 173, in __init__
    index = get_data(index_url, gallery_dir)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lorentzen/github/python3_sklearn/lib/python3.12/site-packages/sphinx_gallery/docs_resolv.py", line 57, in get_data
    search_index = shelve.open(cached_file)
                   ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.1_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/shelve.py", line 243, in open
    return DbfilenameShelf(filename, flag, protocol, writeback)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.1_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/shelve.py", line 227, in __init__
    Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
                         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.1_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/dbm/__init__.py", line 91, in open
    raise error[0]("db type is {0}, but the module is not "
dbm.error: db type is dbm.gnu, but the module is not available

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/lorentzen/github/python3_sklearn/lib/python3.12/site-packages/sphinx/cmd/build.py", line 298, in build_main
    app.build(args.force_all, args.filenames)
  File "/Users/lorentzen/github/python3_sklearn/lib/python3.12/site-packages/sphinx/application.py", line 357, in build
    self.events.emit('build-finished', None)
  File "/Users/lorentzen/github/python3_sklearn/lib/python3.12/site-packages/sphinx/events.py", line 108, in emit
    raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function embed_code_links at 0x12b5ffb00> for event 'build-finished' threw an exception (exception: db type is dbm.gnu, but the module is not available)

Extension error (sphinx_gallery.docs_resolv):
Handler <function embed_code_links at 0x12b5ffb00> for event 'build-finished' threw an exception (exception: db type is dbm.gnu, but the module is not available)
make: *** [html-noplot] Error 2
```

### Versions

```shell
System:
    python: 3.12.1 (main, Dec  7 2023, 20:45:44) [Clang 15.0.0 (clang-1500.1.0.2.5)]
executable: /Users/lorentzen/github/python3_sklearn/bin/python
   machine: macOS-14.4.1-x86_64-i386-64bit

Python dependencies:
      sklearn: 1.5.dev0
          pip: 24.0
   setuptools: 69.2.0
        numpy: 1.26.4
        scipy: 1.13.0
       Cython: 3.0.10
       pandas: 2.2.1
   matplotlib: 3.8.4
       joblib: 1.4.0
threadpoolctl: 3.4.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
    num_threads: 8
         prefix: libomp
       filepath: /usr/local/Cellar/libomp/17.0.6/lib/libomp.dylib
        version: None

       user_api: blas
   internal_api: openblas
    num_threads: 4
         prefix: libopenblas
       filepath: /Users/lorentzen/github/python3_sklearn/lib/python3.12/site-packages/numpy/.dylibs/libopenblas64_.0.dylib
        version: 0.3.23.dev
threading_layer: pthreads
   architecture: Haswell

       user_api: blas
   internal_api: openblas
    num_threads: 4
         prefix: libopenblas
       filepath: /Users/lorentzen/github/python3_sklearn/lib/python3.12/site-packages/scipy/.dylibs/libopenblas.0.dylib
        version: 0.3.26.dev
threading_layer: pthreads
   architecture: Haswell
```
```

COMMENT:
Great!

Labels: Bug, Needs Triage