ModuleNotFoundError: No module named 'torch' - Windows 10

(Maik Rosenheinrich) #1

Hey, I have the following issue - I cloned the github repo to my hdd, installed the conda env, updated the env, rebooted, activated the environment, started jupyter lab and tried to run lesson1.pynb
First I had to change the alias so that windows understood where to look for the fastai library and when that was complete I hit run all cells and:

No module named ‘torch’ was found.

However! when I run !pip list - I can see the module among others:
torch (0.3.1.post2)
torchtext (0.2.1)
torchvision (0.2.0)

can anyone help/explain why this is happening and how to fix it?

complete log:

ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 from fastai.transforms import *
2 from fastai.conv_learner import *
3 from fastai.model import *
4 from fastai.dataset import *
5 from fastai.sgdr import *

D:\github\fastai\courses\dl1\fastai\ in ()
1 from .imports import *
----> 2 from .layer_optimizer import *
3 from enum import IntEnum
5 def scale_min(im, targ):

D:\github\fastai\courses\dl1\fastai\ in ()
1 from .imports import *
----> 2 from .torch_imports import *
3 from .core import *
5 def opt_params(parm, lr, wd):

D:\github\fastai\courses\dl1\fastai\ in ()
1 import os
----> 2 import torch, torchvision, torchtext
3 from torch import nn, cuda, backends, FloatTensor, LongTensor, optim
4 import torch.nn.functional as F
5 from torch.autograd import Variable

ModuleNotFoundError: No module named ‘torch’

(Ralph) #2

I ran into a similar issue with Windows 10. In the end I could only get torch installed with Miniconda.

(Maik Rosenheinrich) #3

Yeah weirdly enough, when I installed pytorch on my base environment it worked?!

(Gokul) #4

Check if usual import from command-line works. If it does, install jupyter for your current environment and restart jupyter notebook. This solves the issue