ModuleNotFoundError: No module named 'fastai.vision.all' on Kaggle Notebook

@NoBlueWithoutYellow I did check on colab. It is working there.
On colab, you would type:
pip install fastai --upgrade and then restart your runtime. Then it should work just fine!

18 Likes

Hello @NoBlueWithoutYellow

I also see this issue intermittently. (It tends to be when I have left the colab notebook for a while and come back to it, Not sure though. I guess its some sort of session related issue with colab.)

I’ve found deleting my copy of the colab notebook and then starting over fixes the issue.
(Make sure you have a copy of any new code in a safe place. etc)

  1. So I go to my google drive, and delete the “Copy of …” version of the notebook there.
  2. Open a new copy from fastai/course-v4 in github
  3. Save that to my google drive
  4. Set the notebook settings to GPU
  5. Click play on the first code cell, and all is fine again.

Hope that helps.

5 Likes

First print out your fastai’s version to see whether it is version 1.xx.
print(fastai.version)
If it is, try to install fastai v2
!pip install fastai==2.0
It should work.

2 Likes

I was having the same problem on Google Colab and this worked for me:

!pip install fastai==2.0
import fastai
print(fastai.__ version __ ) # should be 2.0.0
from fastai.vision.all import *

hope it helps!

(note that the print statement has blank characters before and after “version”. Remove them if you copy paste. (They are there so it doesn’t become like this: print(fastai.version ))

3 Likes

I am using Google Colab. I have upgraded fastai to fastai 2.0.
When i run " from fastai.vision.all import * " i am facing this error,
can you guys please help me?

Thank you in advance

AttributeError Traceback (most recent call last)
in ()
----> 1 from fastai.vision.all import *

9 frames
/usr/local/lib/python3.6/dist-packages/fastcore/utils.py in store_attr(names, self, but, **attrs)
95 args,varargs,keyw,locs = inspect.getargvalues(fr)
96 if self is None: self = locs[args[0]]
—> 97 if not hasattr(self, ‘stored_args’): self.stored_args = {}
98 if attrs: return _store_attr(self, **attrs)
99

AttributeError: ‘str’ object has no attribute ‘stored_args

1 Like

That is because you are installing version 2.0.0 and there have been changes since, the latest version is 2.0.8.

Use:
!pip install fastai --upgrade -q instead and for the moment you will have to downgrade pandas so it is compatible with colab

2 Likes

okk… :sweat_smile: Thank you for your help

2 Likes

Most relevant thing I’ve found after 2 days–but can you please explain to a newbie how to “downgrade pandas so it is compatible with colab”. Thank you in anticipation. (And PS: what are the symptoms that allow one to know to do this? --low priority–I can try it and see.)

1 Like

Glad the info helped :slight_smile: Actually just using:

!pip install fastai --upgrade -q

in colab should do the trick, no need to downgrade pandas any more. That post was a couple of weeks ago and at that point there was a compatibility issue with pandas.

1 Like

Thank you so much; I have finally managed to break the load_learner barrier.
FYI: (actually for the information of other lost souls who arrive here):

Cut back to just the above upgrade and the original’s first from fastai.vision.widgets import *; restarted; clear all; run all

result still NameError: name ‘Path’ is not defined

Added from pathlib import Path

result name ‘load_learner’ is not defined

Added from fastai import * – no improvement

Added **from fastai.basics import *** – this was a w-a guess based on the autocomplete when I was trying to type “basic_train” – it shouldn’t be so obscure. I really thought Colab was the lowest threshold point of entry, but undocumented it certainly can’t work as fastai-for-newbies playground.


Now on to the next hurdle…

.

Proud to say after one more
from fastai.vision.all import *
I uploaded a ginger cat and got it classified as teddy bear with 99% confidence.

This solved my problem. Thank you!

Hi, I just tried doing this myself in colab. I get the error:

AttributeError Traceback (most recent call last)
in ()
1 #hide
----> 2 from fastai.vision.all import *
3 from fastai.text.all import *
4 from fastai.collab import *
5 from fastai.tabular.all import *

3 frames
/usr/local/lib/python3.6/dist-packages/fastai/vision/core.py in ()
22 # Cell
23 if not hasattr(Image,’_patched’):
—> 24 _old_sz = Image.Image.size.fget
25 @patch_property
26 def size(x:Image.Image): return fastuple(_old_sz(x))

AttributeError: type object ‘Image’ has no attribute ‘size’

Any ideas? Thanks!

Hey @Tom26, I am not able to replicate the error. Here is a link to the colab notebook that I used. You can also check the fastai version that is loaded to see if it is the latest version. You may have to just restart the runtime. Let me know if you still have issues.

PyTorch 1.6 and FastAI 2.0 are installed by default in Kaggle Notebooks as of 9/23/2020. Now you can use the following import statements (without the need to do any pip installs):

import torch
import fastai
from fastai.tabular.all import *
from fastai.text.all import *
from fastai.vision.all import *
from fastai.medical.imaging import *
from fastai import *
# etc, etc, etc

2 Likes

Thanks @amritv! Seems to work fine now.

I installed Fastai and other resources on my local machine and I’m getting this error. Thought it belonged to this thread. Can somebody help!

Hi all,
I am quite a newbie but I just upgraded my fastai version as there were some functions I wanted to try.
Now I find out that some parts of my script are not working anymore. I am working in collab.

Such as I cannot do open_image() anymore.
Am I missing a module to load in or do I have to use PIL to open it?

Thank you

Thank you, this worked for me. the instance was running the 1.0.61 version.
Cheers!

3 Likes

Restarting the runtime worked for me thanks!