Error with nbdev.export.nb_export

Hi everyone,

I’ve just started the course on Practical Deep Learning, and I’m trying to follow and do the end-to-end process described in lesson 2.

However, when I use the code described here and here as follows:

import nbdev
nbdev.export.nb_export('app.ipynb', 'app')
print('Export successful')

I get the following error:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-16-2ee21780eaf6> in <module>
      1 import nbdev
----> 2 nbdev.export.nb_export('app.ipynb')
      3 print('Export successful')

6 frames
/usr/lib/python3.7/pathlib.py in _opener(self, name, flags, mode)
   1061     def _opener(self, name, flags, mode=0o666):
   1062         # A stub for the opener argument to built-in open()
-> 1063         return self._accessor.open(self, flags, mode)
   1064 
   1065     def _raw_open(self, flags, mode=0o777):

FileNotFoundError: [Errno 2] No such file or directory: 'app.ipynb'

Any idea on how to solve it or figure out what’s happening? I’m really new into these topics, but I’ve been trying to search in the forums and so on, but I can’t find any solution to it.

For what I think I understand of the error message, it’s looking for ‘app.ipynb’. However, the code should be exporting it, therefore it’s normal that it doesn’t exists already. I’m so confused.

Any help is appreciated! :slight_smile:

1 Like

Seems like you didn’t mention the path where you want to import (after the .ipynb file in the function.

Few checkpoints:

  • Make sure your NB name matches with what you are passing inside the function.

  • Make sure a valid path is set and passed as well.

1 Like

Hi,

I had the same error when running on Google Colab. I noticed that you must specify the whole path for the notebook file. For example, this is how I did it:

from google.colab import drive
drive.mount(‘/content/gdrive’)
path = ‘/content/gdrive/My Drive/ml/fastai/c2/’
nbdev.export.nb_export(path+‘app.ipynb’, path+‘app.py’)

And I had the notebook saved in content/gdrive/My Drive/ml/fastai/c2/ before exporting it to python.

3 Likes