ImportError: No module named torch

I'm trying to install this framework from Github called torch2trt (found here:).

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

git clone
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?

2

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

Otherwise you can check the PyTorch page and try another version.

I would try this one first.

pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f

0

You haven't installed Torch. Install it with pip via:

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like