Error when running either nbdev_build_lib or nbdev_build_docs

(I submitted an identical post on the nbdev github: unsure which is a better platform for an inquiry like this)

When I attempt to run nbdev_build_lib or nbdev_build_docs on an nbdev library that has previously worked very smoothly (see here), I find that I encounter the following error.

Traceback (most recent call last):
  File "/Users/sheridan/opt/anaconda3/envs/pheno/bin/nbdev_build_lib", line 10, in <module>
    sys.exit(nbdev_build_lib())
  File "/Users/sheridan/opt/anaconda3/envs/pheno/lib/python3.9/site-packages/fastcore/script.py", line 113, in _f
    tfunc(**merge(args, args_from_prog(func, xtra)))
  File "/Users/sheridan/opt/anaconda3/envs/pheno/lib/python3.9/site-packages/nbdev/export2html.py", line 477, in nbdev_build_lib
    write_tmpls()
  File "/Users/sheridan/opt/anaconda3/envs/pheno/lib/python3.9/site-packages/nbdev/export2html.py", line 467, in write_tmpls
    cfg = Config()
TypeError: __init__() missing 2 required positional arguments: 'cfg_path' and 'cfg_name'

Any advice on how to resolve this would be greatly appreciated! The only thing I can find online for this is to reinstall nbdev, which I have done a couple of times. I’m not sure this is relevant, but I initially reinstalled nbdev because I was encountering a different (seemingly common) problem wherein running nbdev_build_lib returned the following error:

converting: /Users/sheridan/Academic/bcml4pheno/bcml_model.ipynb
converting: /Users/sheridan/Academic/bcml4pheno/data_vis.ipynb
converting: /Users/sheridan/Academic/bcml4pheno/manual_opt.ipynb
converting: /Users/sheridan/Academic/bcml4pheno/full_example.ipynb
converting: /Users/sheridan/Academic/bcml4pheno/ttbarzp.ipynb
converting: /Users/sheridan/Academic/bcml4pheno/index.ipynb
'HTMLExporter' object has no attribute 'template_path'
'HTMLExporter' object has no attribute 'template_path'
'HTMLExporter' object has no attribute 'template_path'
'HTMLExporter' object has no attribute 'template_path'
'HTMLExporter' object has no attribute 'template_path'
'HTMLExporter' object has no attribute 'template_path'
Traceback (most recent call last):
  File "/Users/sheridan/opt/anaconda3/envs/pheno/bin/nbdev_build_docs", line 10, in <module>
    sys.exit(nbdev_build_docs())
  File "/Users/sheridan/opt/anaconda3/envs/pheno/lib/python3.9/site-packages/fastscript/core.py", line 76, in _f
    func(**args.__dict__)
  File "/Users/sheridan/opt/anaconda3/envs/pheno/lib/python3.9/site-packages/nbdev/cli.py", line 221, in nbdev_build_docs
    notebook2html(fname=fname, force_all=force_all, n_workers=n_workers, pause=pause)
  File "/Users/sheridan/opt/anaconda3/envs/pheno/lib/python3.9/site-packages/nbdev/export2html.py", line 582, in notebook2html
    raise Exception(msg + '\n'.join([f.name for p,f in zip(passed,files) if not p]))
Exception: Conversion failed on the following:
bcml_model.ipynb
data_vis.ipynb
manual_opt.ipynb
ttbarzp.ipynb
full_example.ipynb
index.ipynb

You need to upgrade your fastcore version

How did you install nbdev? Im surprised this keeps happening for folks and I’d love to know how you set it up

Thanks for getting back to me so fast! I apologize but I may need you to elaborate slightly because when I check my fastcore version using conda list fastcore I see the following

# packages in environment at /Users/sheridan/opt/anaconda3/envs/pheno:
#
# Name                    Version                   Build  Channel
fastcore                  1.5.3                      py_0    fastai

and when I go here to the conda webpage for the package that looks like the current version: is it not?

As for how I’m installing nbdev, when I just uninstalled and reinstalled nbdev I ran the following two commands sequentially: is there a better way to do it with conda?

conda remove nbdev
conda install -c fastai nbdev

Hi :slight_smile:

I am also encoutering the exact same issue.

I just discovered nbdev and really wanted to try it out.

I installed it as per the general tutorial and running:

conda install -c fastai nbdev

The first issue I ran into was that the jupyter server would crash because the nbconvert version in env was > 6.

Once that issue was solved I moved on with the tutorial, however when I ran

nbdev_build_lib

I ran in the exact same error as the one posted by sheride.
My version of fastcore is also 1.5.3

Thx in advance for your help.
Regards
Marc

I’m not sure if this will work but can you install nbdev and fastcore from pypi?

Uninstall nbdev and fascore then do a
pip install nbdev and not conda install....

Thx Deven ! :slight_smile:

It did the trick, but required a bit of extra work.

I will try to remember what I had to do for those who might some day have the same issue:

(Sorry for not remembering the exact errors I received)

I ran:
conda remove nbdev
Then:
pip install nbdev
It did not work.
I tried to:
pip install --force-reinstall nbdev
It did not work because some dependencies could not be installed, not even “force-installed”.
I actually had to do some cleanup in python3.10/site-packages/
Some directories had to be removed and the corresponding package re-installed via pip.
Only then did pip install --force-reinstsall nbdev work :sunny:

1 Like

I’d like to concur with mgris and thank Deven for the suggestion: for complete clarity, I copied my conda environment, uninstalled nbdev and fastcore separately using conda, installed nbdev using pip (which installed fastcore), and when I ran nbdev_build_lib I no longer encountered the error.

Just curious, does docment work successfully on your documentation page? I was able create a documentation page on my local server when using nbdev, but was unable to get the docment args to show up. Wonder what’s missing.