Error Loading Notebook - Unreadable Notebook
Problem:
You receive an error message "Unreadable Notebook: <path to a notebook> NotJSONError("Notebook does not appear to be JSON: "...")

Solutions:
Solution 1: Rename the invaid file
If you look in the Jupyter directory for the notebook, you may see that there is another copy of the file with an .invalid extension, and the original is 0 bytes while the .invalid extension one is greater than 0 bytes. If you don't see this, move on to Solution 2.

If this is the case, delete the original notebook that now is 0 bytes and then rename the invalid file to original_filename.ipynb (that is, remove the .invalid extension) and try opening it. You can do this in the Jupyter directory page in the Classic Jupyter Notebook interface.
- Click in the box next to the original file. Then click the trash can icon to delete the file.
- Click in the box next to the invalid file. Then click the Rename button that appears. In the pop-up, remove .invalid from the file name.
- Try opening the file. If it has the content you need then you are good to go. If not, we have two additional solutions we can try.
Solution 2: Restore from the checkpoint file
Open a terminal and change into the course folder, then change into the folder the file is in. List the files in the hidden .ipynb_checkpoints folder with the ls command, using the -a flag to list hidden files, and the -l flag to list long-form details (including the file size.) Hidden folders and files start with a period.
# first change into the course directory and then the folder the file is in
# for instance
cd su25dsa7004*
cd module1/labs
# then list the files in the hidden .ipynb_checkpoints folder
ls -la .ipynb_checkpoints
If you see a file listed <notebook_name>-checkpoint.ipynb and it is not 0 bytes (reading the number between your pawprint and the date), you can restore this file using the cp (copy) command. If you don't see a checkpoint file for the problem notebook, move on to Solution 3.
cp .ipynb_checkpoints/<notebook_name>-checkpoint.ipynb ./<notebook_name>.ipynb
# for instance, to restore L2.2 as shown in the screenshot
cp .ipynb_checkpoints/L2.2-String_Print-checkpoint.ipynb ./L2.2-String_Print.ipynb
Try opening the file. You may have lost some work, but it should open and have some of your work. If the file doesn't open, move on to Solution 3.
Solution 3: Restore to the last commit
You can always restore a file to how it looked at a previous commit. Most likely, the last commit on this file will be what was deployed to you. You will use git checkout <path_to_file> to restore the file. Make sure you put the path to the file! If you use git checkout without the file path, everything in your repository will be reverted to the last commit - you will lose any uncommitted work.
Run git status from inside the course repository. If you are still in the folder the file is in, the path will be different than if you are in the course root, but the commands will all work the same. Running git status lets you get the path correct.
git status
git checkout <path_to_file>
# for example:
git checkout L2.2-Strings_Print.ipynb
# or if I am in the course repo root directory
git checkout module1/labs/L2.2-Strings_Print.ipynb
Need more information or help? Reach out to us at 📧 jcwdw@missouri.edu