ModuleNotFoundError: No module named 'fastai.transforms'

I ran the lesson on my local but got this error.


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 *

ModuleNotFoundError: No module named ‘fastai.transforms’

I already installed fastai.

5 Likes

I randomly get error when any fastai module is importing torch.as_tensor. No module named torch.as_tensor.
I am using google colab. I don’t understand why.

Is the lesson1.ipynb out-of-date?
I pulled the latest fastai and cannot find fastai.transforms. fastai.conv_learner…
only can import fastai.imports

Why?

3 Likes

The line which imports “fastai.transforms” is trying to import the contents in the directory old/fastai. If you are on Windows, the symbolic link might be broken and you have to manually create a sym link using command prompt.

I am having the same issue. I have have both torch and fastai installed. I tried installing with both conda and pip. Issue still remains.

Hi, I had the same problem. Windows is in a kind experimental mode at the moment. Please follow the instruction from this post, Howto: installation on Windows

Hey, I think using
!pip install torchvision fastai==0.6

will solve the problem. Not sure why fastai==0.7 didn’t work for me.

Cheers

2 Likes

fastai==0.7 worked fine for me. I just had to also downgrade torchtext to version 0.2.3

I have the same issue.
I am using version 1.0
I guess maybe fastai.transform no longer exist in latest version.
(I tried to make link, does not work)

1 Like

Hey, but i’m using ubuntu and i still get the same error

I am using google colab and I also have the same problem. I am trying to make a prediction for a single image file that I’ve opened in lesson1 notebook. based on the instructions in the forum, I should first transform my image using tfms_from_model function. However, I get an NameError which says name ‘tfms_from_model’ is not defined. I tried defining it by importing fastai.transforms but I get this error which you are talking about.

many thanks, worked for me too!

This works! Thanks!!

I also have this problem. I use Kaggle. This example works https://www.kaggle.com/hortonhearsafoo/fast-ai-lesson-1 (from fastai.transforms import *)

But if I want to write from fastai.transforms import * I have error (on Kaggle) ModuleNotFoundError: No module named ‘fastai.transforms’

I can run other programs on Kaggle with from fastai.transforms import * but I can not run my program on Kaggle with from fastai.transforms import *

I’m on MacBook Pro. I tried the above suggestion and I still got

ModuleNotFoundError: No module named ‘fast.tabular.transform’

But the imports before that work fine:

from fast.imports import *
from fast.tabluar import *
from fast.tabular.transform import *

The last line is the one that gives me the error!

Please advise.

Thanks!