Leo Gaunt
Leo Gaunt

Reputation: 693

Pytorch isnt found by my code using import torch

I have installed torch using pip. And when I try to run

import torch

I get an error saying

raceback (most recent call last):
  File "C:\Users\leoga\Documents\AI Image Classifier\Classifier.py", line 2, in <module>
    import torch
  File "C:\Python38\lib\site-packages\torch\__init__.py", line 81, in <module>
    ctypes.CDLL(dll)
  File "C:\Python38\lib\ctypes\__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Python38\lib\site-packages\torch\lib\caffe2_nvrtc.dll'. Try using the full path with constructor syntax.

I am using python 3.8

Upvotes: 1

Views: 725

Answers (2)

user14030826
user14030826

Reputation: 23

you may not have the package installed on your computer, use pip (or pip3 if you already have python 2.x installed) to install it

Upvotes: 1

Max Marcus
Max Marcus

Reputation: 106

Have you had python 2.x installed on your computer? It is possible that you need to use

pip3 install torch

if you use just pip instead of pip3 it could install the library in the wrong version of python. If you are on a mac then this is probably the case, as python 2 comes preinstalled on the machine.

Upvotes: 0

Related Questions