[Python] detectron2 installation - No module named 'torch'

Discussão em 'Python' iniciado por Stack, Abril 7, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to install detectron2 on ubuntu and face a weird python dependency problem. In short - pytorch is installed (with pip), torchvision is installed (with pip), but when I run

    pip install 'git+https://github.com/facebookresearch/detectron2.git'


    I get error ModuleNotFoundError: No module named 'torch'

    as for dependencies

    (detectron2_test) ubuntu@LAPTOP:~$ pip install torchvision
    Requirement already satisfied: torchvision in ./detectron2_test/lib/python3.12/site-packages (0.19.1+cu118)
    Requirement already satisfied: numpy in ./detectron2_test/lib/python3.12/site-packages (from torchvision) (1.26.3)
    Requirement already satisfied: torch==2.4.1 in ./detectron2_test/lib/python3.12/site-packages (from torchvision) (2.4.1+cu118)
    (...)

    (detectron2_test) ubuntu@LAPTOP:~$ which pip
    /home/ubuntu/detectron2_test/bin/pip
    (detectron2_test) ubuntu@LAPTOP:~$ which python
    /home/ubuntu/detectron2_test/bin/python
    (detectron2_test) ubuntu@LAPTOP:~$ which python3
    /home/ubuntu/detectron2_test/bin/python3


    Any suggestions are appreciated!

    Continue reading...

Compartilhe esta Página