I'm trying to use (and have successfully installed) Layout Parser, which requires detectron2 for certain functionality. While trying to install detectron2, I ran into the following error:
> python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
[snip]
ModuleNotFoundError: No module named 'torch'
[end of output]
[/snip]
Setting the flags as specified in the installation instructions does nothing:
CC=clang CXX=clang++ ARCHFLAGS="-arch x86_64" pip3 install 'git+https://github.com/facebookresearch/detectron2.git@v0.4#egg=detectron2'
[same output]
Full output of the installation command is at this pastebin.
Modern pip
uses build isolation, it uses a transient virtual env to build a wheel. For packages that don't require build dependencies or packages that declare build dependencies in pyproject.toml
it's not a problem. But the package detectron2
requires torch
and doesn't provide pyproject.toml
.
You can downgrade to older pip
version 22 that doesn't build in an isolated environment. Or disable build isolation using --no-build-isolation
. The full command should be
python -m pip install --no-build-isolation 'git+https://github.com/facebookresearch/detectron2.git'