No module named 'utils'

Hello everybody.
I ecountered a problem with from utils import *.
I tried Google Colab as well as local installation on Windows and Ubuntu - all attempts to execute this line ended with ModuleNotFoundError: No module named ‘utils’.
I tried upgrading fastai, fastcore, jupyter notebook and even anconda but with no result.
I found that there is a typo in the cell called # CLICK ME
“from fastai.vision.all import *” instead of “from fastai2.vision.all import *”
Maybe it’s the same deal with utils and I’m just missing something.
I’m out of ideas here.

Did you install as the book recommends? (pip install fastbook). and follow the directions from here: https://course.fast.ai/start_colab.html

Yup, everything is just like in the instructions

Should be from fastbook import *

@Lucas.J make sure you have the latest version, both fastbook and course-v4 have this

1 Like

I had this issue on the “cleaned” notebooks on colab.

You can only import utils if you cloned the fastbook repo and are working from within.
Else you have to do:
from fastbook import *

Hey guys i’m not able to import utils or fastai.vision.all when i use the clean version of Lesson 1- “01_intro.ipynb”.
I’m using colab for the first time. I setup using the following steps:

  1. opened colab, clicked github and searched for fastai/fastbook, clicked on clean/01_into.ipynb
  2. The notebook opened in a new tab. saved it to my google drive. changed runtime to GPU.
  3. upon executing the first cell i get no module named ‘utils’ (attached image). same with fastai.vision.all

Hi anish.chhaparwal hope all is well!

The standard solution in python to resolve this error, is to install the missing module.

On Colab this can be done using the following command.

!pip install utils

I ran the code below:

#hide
!pip install -Uqq fastbook
import fastbook
fastbook.setup_book()

#hide
from fastbook import *

I agree if you are running notebook listed here https://github.com/fastai/fastbook/blob/master/01_intro.ipynb then utils is not installed.

Cheers mrfabulous1 :smiley: :smiley:

2 Likes

Not quite @mrfabulous1 :slight_smile: the full answer is that notebook most likely is either an old one, or one where the imports were not updated. Utils gets dragged in when we do from fastbook import *, so your second solution is indeed correct!

Good morning muellerzr hope all is well!

To be fair I just went to the fastbook repository on github. 9 minutes ago so where is the best place place to be pulling the latest version of fastai2? :slightly_frowning_face: :slightly_frowning_face:

If I do a !pip freeze after I run the code in the above post shouldn’t I see the utils utility?

Cheers mrfabulous1 :smiley: :smiley:

1 Like

You should instead see the fastbook package! And doing from fastbook import * brings in all the functions from utils :slight_smile:

As to where that package is located, see here: https://github.com/fastai/course20/tree/master/fastbook

Re latest version of fastai, installing fastbook will do so, otherwise do a pip install w/ upgrade for fastai :slight_smile:

1 Like

@mrfabulous1 I did as you suggested and it worked.

@muellerzr Like you suggested I did try to use the package- fastbook but i still had to pip install utils. Secondly, In the clean version of the 01_intro i do not see a import fastbook statement by default. Since not a lot of people are facing the same issue can you point out where i’m going wrong?

P.S: I do not have a coding background so any material on how to clone the entire course from github would help. i’ve read the fastai “how to get started” notebook. TIA
-Anish

What is the fastbook library for, also I can see a utils.py file arent we supposed to use that?