Is nbdev broken on Windows?

Although nbdev worked well for a couple of months, it has now been about 4 weeks since I have been able issue a new release of my main project. It just doesn’t complete the build/CI tasks on github (Linux). It fails on the nbdev_clean_nbs/nbdev_diff_nbs stages, even though the scripts work on my local, Windows, system.

So, I cannot publish a new release of my project, and have spent considerable time trying resolve the problems, unsuccessfully. https://github.com/perceptualrobots/pct.git

Do most people work on Linux? Is there a problem on Windows?

Windows 10
Python 3.7
Anaconda environments.

I have created a new, virtually empty project and even that fails, https://github.com/perceptualrobots/epct.git.

Following the tutorial, I have installed nbdev 1.1.4, but nbdev_build_lib fails on the #default_exp core line:

(pctdev37) C:\Users\ruper\Versioning\python\nbdev\epct>nbdev_build_lib
Converted 00_core.ipynb.
No export destination, ignored:
#export
def myfuncx(a):
return a + 1
Warning: Exporting to “None.py” but this module is not part of this build
Traceback (most recent call last):
File “c:\users\ruper.conda\envs\pctdev37\lib\runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “c:\users\ruper.conda\envs\pctdev37\lib\runpy.py”, line 85, in run_code
exec(code, run_globals)
File "C:\Users\ruper.conda\envs\pctdev37\Scripts\nbdev_build_lib.exe_main
.py", line 7, in
File “c:\users\ruper.conda\envs\pctdev37\lib\site-packages\fastcore\script.py”, line 85, in _f
tfunc(**merge(args, args_from_prog(func, xtra)))
File “c:\users\ruper.conda\envs\pctdev37\lib\site-packages\nbdev\export2html.py”, line 478, in nbdev_build_lib
notebook2script(fname=fname)
File “c:\users\ruper.conda\envs\pctdev37\lib\site-packages\nbdev\export.py”, line 413, in notebook2script
for f in sorted(files): d = _notebook2script(f, modules, silent=silent, to_dict=d)
File “c:\users\ruper.conda\envs\pctdev37\lib\site-packages\nbdev\export.py”, line 351, in _notebook2script
if to_dict is None: _add2all(fname_out, [f"’{f}’" for f in names if ‘.’ not in f and len(f) > 0] + extra)
File “c:\users\ruper.conda\envs\pctdev37\lib\site-packages\nbdev\export.py”, line 206, in _add2all
with open(fname, ‘r’, encoding=‘utf8’) as f: text = f.read()
FileNotFoundError: [Errno 2] No such file or directory: ‘C:\Users\ruper\Versioning\python\nbdev\epct\epct\None.py’

I then upgraded to nbdev 0.2.20.

The main project was failing on github on nbdev_diff_nbs (but not on Windows).

I disabled nbdev_diff_nbs in main.yml and github got to the nbdev_test_nbs stage, but it failed with,


from nbdev import *
%nbdev_default_export core

UsageError: Line magic function %nbdev_default_export not found.

Anyone know what on earth is going on?

1 Like

I think this is because magic flags were removed after nbdev 1.0.14.

A quick fix might be to pin versions of nbdev and fastcore/fastscript e.g.
pip install fastscript==1.0.0 fastcore==1.0.8 nbdev==1.0.14

but … it might be better to convert your notebooks to use comment flags instead.

You could write a simple “find and replace” script for the flags that you have used. If you have a lot to convert, reversing the logic in _migrate2magic should give you a robust solution.

Oh, I thought it was quite recently they were added, in 0.2.20.

Is it going back to #export etc? How come?

Yep, going back to #export etc. See: https://twitter.com/fastdotai/status/1306382636957315072

1 Like