NameError: name 'IN_NOTEBOOK' is not defined


I’m trying to set up the notebooks and run the code in 01_intro, but I’ve been hit with the same error on two different platforms.

If I try to run the first cell:

!pip install -Uqq fastbook
import fastbook

I get a NameError: name ‘IN_NOTEBOOK’ is not defined. I get this error on gradient and in DataCrunch. Is there something I’m not setting up properly, or has anyone had any similar problems?

Any help would be greatly appreciated, as I feel like I’m missing something obvious. Thankyou in advance!



I am also having the same problem, I just made the environment and updated according to,

I think is due to some recent commit in their git or a mistake in the library fastbook or fastai.

I will try resetting my paperspace machine and return if the error is solved

More details on the problem:

1 #hide
----> 2 from utils import *

/notebooks/course-v4/nbs/ in
1 # Numpy and pandas by default assume a narrow screen - this fixes that
2 from import *
----> 3 from nbdev.showdoc import *
4 from ipywidgets import widgets
5 from pandas.api.types import CategoricalDtype

/opt/conda/envs/fastai/lib/python3.8/site-packages/nbdev/ in
6 from .flags import *
----> 7 from .showdoc import show_doc
8 #from .export import notebook2script

/opt/conda/envs/fastai/lib/python3.8/site-packages/nbdev/ in
12 from nbconvert import HTMLExporter
—> 14 if IN_NOTEBOOK:
15 from IPython.display import Markdown,display
16 from IPython.core import page

NameError: name ‘IN_NOTEBOOK’ is not defined

I think I fixed the problem by running in terminal:

pip install nbdev --upgrade

then shutdown the notebook if running and re-open.


Thankyou so much! This seemed to work for me great!

Worked for me too! thanks!

Thank-you, that’s happened a couple of times now with DataCrunch too, and that process worked. I started the terminal and used the pip install nbdev --upgrade . Re-tried without shutting down the notebook, and it failed, but once I shutdown the notebook and restarted, it all worked. Many thanks.

1 Like

I am very happy that I managed to help some people! You guys are wonderful :slight_smile:

1 Like

thank you I was having the same issue and this is the fix.

Thanks, this got the issue fixed :+1:t2:

Thanks, this worked for me!

Thanks, this worked for me as well!