No module named 'fastai.data' in Google Colab

Installing fastai on Google Colab with “!pip install fastai” command (installation went ok)
-> try to run examples from this tutorial
-> from fastai.data.all import *
from fastai.vision.all import *
-> get error No module named ‘fastai.data’

is pip install fastai installing fastai2? If not, how to install fastai2 on Google Colab?
Thank you!

I’ve been having trouble with fastai in Colab as well (I’m new to Colab). In Colab I’ve had to run !pip install -U fastai (the “-U” upgrades). You can check the version with fastai. _ _ version _ _ (no spaces)

But after that I still get " ‘str’ object has no attribute ‘stored_args’ " when I try to run this: “from fastai.vision.all import *”. I’m trying to follow the quick start .ipynb: https://docs.fast.ai/quick_start.html. I found some information in this thread. But not enough to fix this.

I also got the “No module named ‘fastai.data’” when I try to import that. But maybe that has to do with the change from fastai1 to fastai2?

Not sure where to go next. Have I corrupted my Colab environment somehow? Is that even possible?

Now I’m able to get “quick start.ipynb” from the docs to work with
!pip install -U fastai (which gives me 2.0.8)
This also allows me to import “fastai.data”

I think the other issues were because I tried to install fastai==2.0.0 which may have been a bit outdated. Let me know if the !pip install -U fastai works for you or if we need to do more troubleshooting.

1 Like

I’m able to install fastai2 on Google Colab from git:

!pip install git+https://github.com/fastai/fastai.git
I’ve also had problems with pandas (sporadic issue) - df.head() function would fail with
"Nonetype" has no attribute "items".
“!pip install pandas” will install 1.0.5 version (not latest). After manually installing latest pandas version:
!pip install -Iv pandas=1.1.1
It worked fine. But, I suppose, problems with other packages like pandas may arrise too,

2 Likes

That other thread mentioned issues because google-colab is only compatible with pandas~=1.0.0. Not sure if that is the cause here.

When I install fastai on my local machine (new empty environment) I have pandas=1.1.1 (latest version) installed.
But on Colab pandas is preinstalled and is not updated by the fastai. In fastai repo you can find settings.ini file and the line there:

requirements = fastcore>=1.0.0 torchvision>=0.7 matplotlib pandas requests pyyaml fastprogress>=0.2.4 pillow scikit-learn scipy spacy pandas>=1.1.0

I suppose that problem is that two pandas pckgs are mentioned and while installing the second req (pandas>=1.1.0) will somehow be ignored.