python - Can't run pytest with a `FileNotFoundError: [Errno 2] No such file or directory: 'tmppip-build-env-3fag

时间: 2025-01-06 admin 业界

I have tried many things like upgrading pip, pytest etc etc but nothing works. I have a fork of scikit-learn and working on some new functionality and would like to run all the unit tests but I can't:

(myenv) xxx@Thor:~/code/scikit-learn$ pytest
ImportError while loading conftest '/home/xxx/code/scikit-learn/sklearn/conftest.py'.
/opt/dev/myenv/lib/python3.9/site-packages/_scikit_learn_editable_loader.py:311: in find_spec
    tree = self._rebuild()
/opt/dev/myenv/lib/python3.9/site-packages/_scikit_learn_editable_loader.py:345: in _rebuild
    subprocess.run(self._build_cmd, cwd=self._build_path, env=env, stdout=subprocess.DEVNULL, check=True)
/opt/dev/miniconda3/lib/python3.9/subprocess.py:505: in run
    with Popen(*popenargs, **kwargs) as process:
/opt/dev/miniconda3/lib/python3.9/subprocess.py:951: in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
/opt/dev/miniconda3/lib/python3.9/subprocess.py:1821: in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
E   FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-build-env-3fagdb36/normal/bin/ninja'

I have attempted the following (existing SO answers) but none work:

sudo apt update
sudo apt install -y ninja-build

and then also:

CMAKE_ARGS="-DGGML_CUDA=on -DLLAVA_BUILD=off" FORCE_CMAKE=1 pip install  llama-cpp-python --no-cache-dir