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:
Virchan, thank you for providing these hints and explanation.

Labels: Bug, Needs Triage