How to avoid Keyerror named 'kernelspec' in Papermill? How to avoid Keyerror named 'kernelspec' in Papermill? python-3.x python-3.x

How to avoid Keyerror named 'kernelspec' in Papermill?


Jupyter adds metadata to your notebook. Your error is related to the fact some metadata, under key kernelspec, are missing.

Example of the kernelspec object in notebook metadata:

"kernelspec": {    "display_name": "Python 3",    "language": "python",    "name": "python3"}

Thus, to solve your error you need to correct the notebook metadata to add a correct kernelspec object. The most simple way of doing this if to edit the notebook JSON document and add a kernelspec object in the metadata first level object.

"metadata": {    "kernelspec": {        "display_name": "Python 3",        "language": "python",        "name": "python3"    },    "language_info": {        "codemirror_mode": {            "name": "python",            "version": 3        }    }}

Your error might come from the fact you are using a cleaner to get read out of notebook outputs like nbstripout python package. If that's the case, take care changing nbstripout settings following the documentation.