Ipykernel_launcher.py: error: unrecognized arguments

TLDR: Check if you are accidently exporting the nbdev_export line of the notebook.


I just fixed an issue with nbdev that I could see other people running into. This was the stack trace when I tried to import functions from my nbdev lib:

usage: ipykernel_launcher.py [-h] [--path PATH] [--symlinks] [--file_glob FILE_GLOB] [--file_re FILE_RE]
                             [--folder_re FOLDER_RE] [--skip_file_glob SKIP_FILE_GLOB] [--skip_file_re SKIP_FILE_RE]
                             [--skip_folder_re SKIP_FOLDER_RE] [--procs [{black_format,scrub_magics} ...]]
ipykernel_launcher.py: error: unrecognized arguments: -f /home/user/.local/share/jupyter/runtime/kernel-dbf502e1-cc46-4dfa-b043-734d74ff5843.json
An exception has occurred, use %tb to see the full traceback.

SystemExit: 2

Eventually, I ran the %tb that is mentioned and saw the nbdev_export line was not processing correctly when being exported. After removing the export directive from this line, everything works as expected.