Detectron2 Installation on windows 11 issue CPU only

username: hasanradi93
cooked: <p>I attempted to utilize the detectron2 module from Facebook. I tried installing it on Windows 11 using only the CPU with the following command: “&gt;pip install -e git+https://github.com/facebookresearch/detectron2.git@v0.4#egg=detectron2”. However, it resulted in an error. Can you provide any assistance?</p>
<pre><code class="lang-auto">ImportError:
Detectron2LayoutModel requires the detectron2 library but it was not found in your environment. Checkout the instructions on the
installation page: https://github.com/facebookresearch/detectron2/blob/master/INSTALL.md and follow the ones
that match your environment. Typically the following would work for MacOS or Linux CPU machines:   
    pip install 'git+https://github.com/facebookresearch/detectron2.git@v0.4#egg=detectron2'  
</code></pre>
<pre><code class="lang-auto">    c1xx: fatal error C1083: Cannot open source file: 'C:\Windows\System32\src\detectron2\detectron2\layers\csrc\nms_rotated\nms_rotated_cpu.cpp': No such file or directory
    ninja: build stopped: subcommand failed.
    Traceback (most recent call last):
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\torch\utils\cpp_extension.py", line 2100, in _run_ninja_build
        subprocess.run(
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\subprocess.py", line 569, in run
        raise CalledProcessError(retcode, process.args,
    subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last):
      File "&lt;string&gt;", line 2, in &lt;module&gt;
      File "&lt;pip-setuptools-caller&gt;", line 34, in &lt;module&gt;
      File "C:\Windows\System32\src\detectron2\setup.py", line 191, in &lt;module&gt;
        setup(
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\__init__.py", line 107, in setup
        return distutils.core.setup(**attrs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
        return run_commands(dist)
               ^^^^^^^^^^^^^^^^^^
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
        dist.run_commands()
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands
        self.run_command(cmd)
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\dist.py", line 1234, in run_command
        super().run_command(command)
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
        cmd_obj.run()
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\command\develop.py", line 34, in run
        self.install_for_development()
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\command\develop.py", line 111, in install_for_development
        self.run_command('build_ext')
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
        self.distribution.run_command(command)
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\dist.py", line 1234, in run_command
        super().run_command(command)
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
        cmd_obj.run()
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\command\build_ext.py", line 84, in run
        _build_ext.run(self)
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 345, in run
        self.build_extensions()
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\torch\utils\cpp_extension.py", line 873, in build_extensions
        build_ext.build_extensions(self)
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 467, in build_extensions
        self._build_extensions_serial()
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 493, in _build_extensions_serial
        self.build_extension(ext)
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\command\build_ext.py", line 246, in build_extension
        _build_ext.build_extension(self, ext)
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\Cython\Distutils\build_ext.py", line 135, in build_extension
        super(build_ext, self).build_extension(ext)
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 548, in build_extension
        objects = self.compiler.compile(
                  ^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\torch\utils\cpp_extension.py", line 845, in win_wrap_ninja_compile
        _write_ninja_file_and_compile_objects(
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\torch\utils\cpp_extension.py", line 1774, in _write_ninja_file_and_compile_objects
        _run_ninja_build(
      File "C:\Users\hassa\anaconda3\envs\env_python3.11.0\Lib\site-packages\torch\utils\cpp_extension.py", line 2116, in _run_ninja_build
        raise RuntimeError(message) from e
    RuntimeError: Error compiling objects for extension
    [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
</code></pre>