ImportError: No module named torch

Viewed 13248

I'm trying to install this framework from Github called torch2trt (found here:https://github.com/NVIDIA-AI-IOT/torch2trt).

I ran the following code in a Python terminal to install it:

git clone https://github.com/NVIDIA-AI-IOT/torch2trt
cd torch2trt
python setup.py install

but ended up with the following error message:

Traceback (most recent call last):
  File "setup.py", line 2, in <module>
    import torch
ImportError: No module named torch

I have already installed pytorch using pip install torch torchvision

Does anyone know how to resolve this?

5 Answers

Try running everything in python3:

python3 -m pip install torch torchvision

followed by :

python3 setup.py install

In Linux,

which python
which pip

In Windows power shell

where python
where pip

Check if both pip and python are from same parent directory.

python defaults to python2

So you should change python setup.py install to python3 setup.py install

Related