Quick Start Problems Code Run Problemss

I have copied all the code modules into Colab and tried running each code examples and none of it works.

What am I missing?

Does anyone have a version of these code modules that work?

You need to install fastai2 and restart the runtime (ctrl-M .) or try this (it works with my Colab at leat) in the very first cell (run the cell twice):

# from fastai2.vision.all import *

try: from fastai.vision.all import *
except ModuleNotFoundError:
  !pip install -Uqq fastai
  try: from fastai.vision.all import *
  except ModuleNotFoundError:
    import os
    os._exit(0)
# run this cell twice

@mikeee why not simply do !pip install -Uqq fastai before importing any fastai modules in colab notebooks?

Thank you for you response but as I understand it, fastat2 is already installed in Colab so I do not understand why you want me to install it.

No, as for now colab has fastai 1.x preinstalled

btw you can run code from the book on colab taking it in the book repository. In this way you should avoid all the setup issues

Hi arampacha,

So the instructions you gave me installs fastai2 and overrides v1 on Colab—is that correct?

Thanks.

yep, -U options tells pip to upgrade libraries to latest versions, and qq is for quiet, so pip doesn’t print all it’s output

This is error I got and installing fastai2 and running code.

Any suggestions?

DanDunneCode1.pdf (118.9 KB)

Thanks.

Try run

from fastai.data.all import *

or

from fastai.vision.all import *

or

from fastai.text.all import *

first (assuming fastai2). untar_data is in fact in data/external.py. But any of the above imports will automatically import all functions in external.py I think (data/all.py (vision/all.py, text/all.py) takes care of it).