Hi, I have a problem with nbdev and notebook2script . I have installed the following versions: nbdev 2.3.6; notebook2script 0.2.1.
When I try to run from nbdev.export import notebook2script I get the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Input In [30], in <cell line: 1>()
----> 1 from nbdev.export import notebook2script
ImportError: cannot import name 'notebook2script' from 'nbdev.export' (/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nbdev/export.py)
Thank you @chrwittm, I had trouble with that!
I’ll add that the 2nd parameter to nb_export is the directory path and not the filename, so if you wish to create the Python file directly in the same dir as your notebook, you can do this: nbdev.export.nb_export('app.ipynb', './')
You might see ExportModuleProc._default_exp_() missing 1 required positional argument: 'exp_to' if you’ve called #|default_exp without a filename. So just run the cell again as #|default_exp app and then nbdev.export.nb_export('app.ipynb').
And I would like to add to @chrwittm and @dway8 comments that if it’s running without error but it’s not creating any .py file for you, it’s because you need to install JupyterLab Extension. If you are using pip you can run below:
pip install jupyterlab-quarto
Here is the link for other ways of its installation:
I have the same problem with notebook2script. Kaggle does not run it and locally it is not working after conda installations and pip installations.
The above solution did not work. to uninstall do
Ahh, ok. I should have specified that I was working locally with the notebook file in my root directory, good point.
Do you have #|default_exp INSERT_EXPORT_FILE_NAME in the top of the first cell of your notebook? That’s the only thing I can think of without seeing the rest of you code.
If that doesn’t work I’d be happy to I’d be happy to take a look if you can send me a link to your notebook.
Line 3 just specifies the location within your project folder where the file should be sent. Using “.” means “root” directory so if your folder structure is:
project_folder/ <----- this is the "root" directory
├── sub_folder_1/
└── sub_folder_2/
you would end up with:
project_folder/
├── sub_folder_1/
├── sub_folder_2/
└── app.py <----- exported here
if you replaced the export_destination = "." with export_destination = "sub_folder_1/" then you would end up with: