You should use `except nbformat.NotJSONError` or something similar to make sure this is actually the error you are catching.