What happened to docs()?

I’m sure I am doing something wrong here but I can’t get docs to work from a notebook.

I am running these imports (copied from lesson1).

from fastai.vision import *
from fastai.metrics import error_rate

then trying to run

docs(ImageDataBunch)

Then I get:


NameError Traceback (most recent call last)
in
----> 1 docs(ImageDataBunch)

NameError: name ‘docs’ is not defined

What am I missing? I tried to search around for the function in the docs website but no luck.

Thanks

1 Like

Try doc(ImageDataBunch)

Works for me

What imports do you have?
What version do you have installed? How did you install it?

Thanks

What imports do you have? from fastai.vision import *

What version do you have installed? 1.0.51

How did you install it? I am using google colab. I ran the following in a cell: !pip install fastai --upgrade

Very strange for me. I created a new conda environment and ran this from a jupyter cell and docs works. It looked like it was installing fastai to my main python install.

but I can’t get docs to work in my other environments. regardless of where i run that command…

It’s doc, not docs.

Neither work.

@jeremy any other ideas?

Your fastai must be out of date. Check http://docs.fast.ai for troubleshooting.

I’m on 1.0.51

@jeremy
It seems the specific way of creating the virtual environment has an affect if doc works or not.

Note the only difference is the anaconda included in the first “conda create” command

This works:
conda create -n doc_test5 python=3.6 anaconda
conda activate doc_test5
conda install -c pytorch -c fastai fastai
(doc_test5) ubuntu@ip-172-31-29-142:~$ python
Python 3.6.8 |Anaconda custom (64-bit)| (default, Dec 30 2018, 01:22:34)
[GCC 7.3.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>> from fastai.vision import *
>>> doc()
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
TypeError: doc() missing 1 required positional argument: ‘elt’

This does not work:
conda create -n doc_test6 python=3.6
conda activate doc_test6
conda install -c pytorch -c fastai fastai
(doc_test6) ubuntu@ip-172-31-29-142:~$ python
Python 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34)
[GCC 7.3.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>> from fastai.vision import *
>>> doc()
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
NameError: name ‘doc’ is not defined

I looked through some fast.ai documentation and it does not specify to use the anaconda in the conda create command.

2 Likes

The difference between:
conda create -n myenv python=x.x and conda create -n myenv python=x.x anaconda
The first installs bare minimum set up with no additional packages
The second installs anaconda packages

So possibly a missing anaconda package or missing config path in environment?

A failed experiment:
Hypothesis we are missing a package:-

I note in a fresh bare minimum environment running “conda install anaconda” will install all the anaconda packages.

Running “conda install anaconda” in a fastai conda environment results in only a single anaconda package being installed. However this new updated environment also fails with the same NameError: name ‘doc’ is not defined when used in Jupyter.

1 Like

I have the missing doc problem and when I import it directly.
from fastai.gen_doc.nbdoc import doc
I was missing nbformat and nbconvert after the clean conda install.
-Ric

2 Likes

I still have this problem. @source99’s proposed solution does not work for me.
Edit: It does when using Python 3.6, but not when using Python 3.7.

This solved for me:
conda install nbformat nbconvert

4 Likes

Worked for me, but I had to restart the kernel in order for the open notebook to be able to use it.

1 Like

with python -m pip install ipywidgets solved

This solved it for me too! Thanks!

@source99: Hi!

I came across the same issue: NameError: name 'doc' is not defined in lesson 1. When debugging CUDA memory errors deeper in lesson 1.

Since when running all cells above this point the issue goes away, it must be a missing library problem. After some fishing for what is missing fastbook lib seems to be it.

This one line solves the error for me:
from fastbook import *

#two errors solved:
# -- NameError: name 'doc' is not defined
# -- NameError: name 'fine_tune' is not defined
from fastbook import *

#doc(Learner) 
doc(Learner.fine_tune)
doc(Learner.fit_one_cycle)

I hope this helps!

Best
PO

1 Like