Failure generating a pdf of the documentations using make latexpdf

### Describe the bug

Hi sklearn team and fans,

I am trying to generate a pdf of the documentations to be able to read/use sklearn documentations offline. On multiple systems ranging from Macos (ARM or AMD processors) to Ubuntu, I am facing this issue and I am unable to troubleshoot it further:

```
Configuration error:
There is a programmable error in your configuration file:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniconda/base/envs/sklearn_docs/lib/python3.10/site-packages/sphinx/config.py", line 509, in eval_config_file
    exec(code, namespace)  # NoQA: S102
  File "/Users/myself/Documents/sklearn_docs/scikit-learn/doc/conf.py", line 22, in <module>
    from sklearn.externals._packaging.version import parse
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1002, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 945, in _find_spec
  File "/opt/homebrew/Caskroom/miniconda/base/envs/sklearn_docs/lib/python3.10/site-packages/_scikit_learn_editable_loader.py", line 311, in find_spec
    tree = self._rebuild()
  File "/opt/homebrew/Caskroom/miniconda/base/envs/sklearn_docs/lib/python3.10/site-packages/_scikit_learn_editable_loader.py", line 345, in _rebuild
    subprocess.run(self._build_cmd, cwd=self._build_path, env=env, stdout=subprocess.DEVNULL, check=True)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/sklearn_docs/lib/python3.10/subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/opt/homebrew/Caskroom/miniconda/base/envs/sklearn_docs/lib/python3.10/subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/opt/homebrew/Caskroom/miniconda/base/envs/sklearn_docs/lib/python3.10/subprocess.py", line 1842, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/2k/k1vr0xc11hd8_n10w_v242k80000gn/T/pip-build-env-8s67iqiw/overlay/bin/ninja'

make: *** [latexpdf] Error 2
```
First, are we able to utilize the `make latexpdf` to automate the generation of a pdf for the entire documentation? If no, just indicate so. If yes, then, how would you recommend I resolve ot troubkeshoot this issue further? As you can see, the error trace poitns to multiple files in sklearn and I thought I can bring this issue up.

Thanks and best regards

### Steps/Code to Reproduce

```
pip install sphinx sphinx-gallery numpydoc matplotlib Pillow pandas scikit-image joblib
cd doc
pip install --editable ..
make latexpdf
```


### Expected Results

No error is thrown and a pdf for the documentations is generated

### Actual Results

`Configuration error:
There is a programmable error in your configuration file:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniconda/base/envs/sklearn_docs/lib/python3.10/site-packages/sphinx/config.py", line 509, in eval_config_file
    exec(code, namespace)  # NoQA: S102
  File "/Users/myself/Documents/sklearn_docs/scikit-learn/doc/conf.py", line 22, in <module>
    from sklearn.externals._packaging.version import parse
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1002, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 945, in _find_spec
  File "/opt/homebrew/Caskroom/miniconda/base/envs/sklearn_docs/lib/python3.10/site-packages/_scikit_learn_editable_loader.py", line 311, in find_spec
    tree = self._rebuild()
  File "/opt/homebrew/Caskroom/miniconda/base/envs/sklearn_docs/lib/python3.10/site-packages/_scikit_learn_editable_loader.py", line 345, in _rebuild
    subprocess.run(self._build_cmd, cwd=self._build_path, env=env, stdout=subprocess.DEVNULL, check=True)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/sklearn_docs/lib/python3.10/subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/opt/homebrew/Caskroom/miniconda/base/envs/sklearn_docs/lib/python3.10/subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/opt/homebrew/Caskroom/miniconda/base/envs/sklearn_docs/lib/python3.10/subprocess.py", line 1842, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/2k/k1vr0xc11hd8_n10w_v242k80000gn/T/pip-build-env-8s67iqiw/overlay/bin/ninja'

make: *** [latexpdf] Error 2
`

### Versions

```shell
here are all the packages installed in the conda env I am trying to use to generate this pdf document:

alabaster==0.7.16
babel==2.16.0
certifi==2024.12.14
charset-normalizer==3.4.1
contourpy==1.3.1
cycler==0.12.1
Cython==3.0.11
distlib==0.3.6
docutils==0.21.2
filelock==3.10.4
fonttools==4.55.3
idna==3.10
imageio==2.36.1
imagesize==1.4.1
Jinja2==3.1.5
joblib==1.4.2
kiwisolver==1.4.8
lazy_loader==0.4
MarkupSafe==3.0.2
matplotlib==3.10.0
networkx==3.4.2
numpy==2.2.1
numpydoc==1.8.0
packaging==24.2
pandas==2.2.3
pillow==11.0.0
Pygments==2.18.0
pyparsing==3.2.0
python-dateutil==2.9.0.post0
pytz==2024.2
requests==2.32.3
scikit-image==0.25.0
-e git+https://github.com/scikit-learn/scikit-learn.git@970503f839f44b4f78390e6069f8e13c0dd2f185#egg=scikit_learn
scipy==1.14.1
six==1.17.0
snowballstemmer==2.2.0
Sphinx==7.3.7
sphinx-gallery==0.18.0
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
tabulate==0.9.0
threadpoolctl==3.5.0
tifffile==2024.12.12
tomli==2.2.1
tzdata==2024.2
urllib3==2.3.0
virtualenv==20.21.0
```

COMMENT:
Here is a list of all the files in the `doc/_build/latex` directory:

```
(sklearn-env) user@macbookair:~/scikit-learn/doc/_build/latex$ ls -al
total 452
drwxrwxr-x 4 user user  4096 Dec 26 12:48 .
drwxrwxr-x 6 user user  4096 Dec 26 13:02 ..
-rw-rw-r-- 1 user user   684 Dec 26 13:11 latexmkjarc
-rw-rw-r-- 1 user user   405 Dec 26 13:11 latexmkrc
-rw-rw-r-- 1 user user 18890 Dec 26 11:56 LatinRules.xdy
-rw-rw-r-- 1 user user  4366 Dec 26 11:56 LICRcyr2utf8.xdy
-rw-rw-r-- 1 user user 10188 Dec 26 11:56 LICRlatin2utf8.xdy
-rw-rw-r-- 1 user user   473 Dec 26 13:11 make.bat
-rw-rw-r-- 1 user user  1590 Dec 26 13:19 Makefile
-rw-rw-r-- 1 user user   392 Dec 26 11:56 python.ist
-rw-rw-r-- 1 user user 10879 Dec 26 11:43 scikit-learn-logo.png
drwxrwxr-x 2 user user  4096 Dec 26 12:41 _sphinx_design_static
-rw-rw-r-- 1 user user  7553 Dec 26 13:11 sphinxhighlight.sty
-rw-rw-r-- 1 user user  3256 Dec 26 11:56 sphinxhowto.cls
-rw-rw-r-- 1 user user 19110 Dec 26 11:56 sphinxlatexadmonitions.sty
-rw-rw-r-- 1 user user   900 Dec 26 11:56 sphinxlatexcontainers.sty
-rw-rw-r-- 1 user user  4918 Dec 26 11:56 sphinxlatexgraphics.sty
-rw-rw-r-- 1 user user  2065 Dec 26 11:56 sphinxlatexindbibtoc.sty
-rw-rw-r-- 1 user user  5138 Dec 26 11:56 sphinxlatexlists.sty
-rw-rw-r-- 1 user user 45860 Dec 26 11:56 sphinxlatexliterals.sty
-rw-rw-r-- 1 user user  5419 Dec 26 11:56 sphinxlatexnumfig.sty
-rw-rw-r-- 1 user user 14353 Dec 26 11:56 sphinxlatexobjects.sty
-rw-rw-r-- 1 user user  8437 Dec 26 11:56 sphinxlatexshadowbox.sty
-rw-rw-r-- 1 user user  3742 Dec 26 11:56 sphinxlatexstyleheadings.sty
-rw-rw-r-- 1 user user  2671 Dec 26 11:56 sphinxlatexstylepage.sty
-rw-rw-r-- 1 user user  6759 Dec 26 11:56 sphinxlatexstyletext.sty
-rw-rw-r-- 1 user user 57643 Dec 26 11:56 sphinxlatextables.sty
-rw-rw-r-- 1 user user  4241 Dec 26 11:56 sphinxmanual.cls
-rw-rw-r-- 1 user user   745 Dec 26 13:11 sphinxmessages.sty
-rw-rw-r-- 1 user user  2060 Dec 26 11:56 sphinxoptionsgeometry.sty
-rw-rw-r-- 1 user user  1093 Dec 26 11:56 sphinxoptionshyperref.sty
-rw-rw-r-- 1 user user 36106 Dec 26 11:56 sphinxpackageboxes.sty
-rw-rw-r-- 1 user user  2590 Dec 26 11:56 sphinxpackagecyrillic.sty
-rw-rw-r-- 1 user user 15330 Dec 26 11:56 sphinxpackagefootnote.sty
-rw-rw-r-- 1 user user   755 Dec 26 11:56 sphinxpackagesubstitutefont.sty
-rw-rw-r-- 1 user user 54119 Dec 26 11:56 sphinx.sty
-rw-rw-r-- 1 user user  9475 Dec 26 11:56 sphinx.xdy
drwxrwxr-x 2 user user  4096 Dec 26 12:05 _static

```

There are not any *.tex files!

Labels: Bug, Needs Triage