nbdev
nbdev copied to clipboard
`nbdev_clean` fails to clean a notebook because it cannot decode some byte
I have been having issues with nbdev_clean. I narrowed down the notebook that is having problems being cleaned and the issue seems to be with quotation characters. In the below Copyright message (based on that from the nbdev repo), the quotations around the word License seem to be the center of the problem:
Copyright © 2019 onward Hyun Jong Kim. Licensed under the Apache License, Version 2.0 (the “License”); you may not use this project’s files except in compliance with the License. A copy of the License is provided in the LICENSE file in this repository.
The following is the error message:
(trouver_py310_venv) C:\Users\hyunj\Documents\Development\Python\trouver>nbdev_clean --fname nbs/index.ipynb
C:\Users\hyunj\Documents\Development\Python\trouver_py310_venv\lib\site-packages\nbdev\clean.py:115: UserWarning: Failed to clean notebook
warn(f'{warn_msg}')
C:\Users\hyunj\Documents\Development\Python\trouver_py310_venv\lib\site-packages\nbdev\clean.py:116: UserWarning: 'charmap' codec can't decode byte 0x9d in position 32929: character maps to <undefined>
warn(e)
It may be relevant to note that I am using a Windows computer, the above error message was produced on command line, and that the editors I am using (VSCode to edit/read and Notepad++ to read) are set to encode files in UTF-8.
Beyond the block of text from the above diagnosis, the example that am working with is from a library that I am developing using nbdev. The problem is not in the master branch (because I neglected to include a License statement), but rather is the develop branch.
Edit: I should add that the develop branch has since been updated and in particular, the quotation marks have been replaced with these ones: "" and the error no longer arises. The quotation marks on the License statement above should still cause problems, however.
Maybe related: https://forums.fast.ai/t/nbdev-export-raises-jsondecodeerror/103606/3
Myself, I was seeing the issue in the README.md generated by my index.ipynb. What triggered the error was trying to pip install -e .. Then the JSONDecodeError arose from this expression in setup.py: long_description = open('README.md').read().
@hyunjongkimmath I think the issue is arising from running nbdev on windows. Can you run it in WSL and see if the issue still persists?