← Back to Blog
Friday, January 6 2023

Jupyter Notebook is not utf-8 encoded – How to fix for good

Fix Jupyter Notebook is not utf-8 encoded error using these 4 simple steps. Explore the solutions to commonly faced issues of utf-8 encoding in Jupyter.

Jupyter notebook is not encoded in UTF-8: The Cause

If you are seeing an error message stating that a Jupyter notebook is not encoded in UTF-8, it means that the notebook file is not saved in the correct encoding and cannot be displayed correctly.

This can cause issues with special characters and non-Latin scripts, as they may be displayed as garbled text or not displayed at all. To fix this issue, you will need to save the notebook file with the correct encoding and then reopen it in Jupyter. The following steps outline how to do this.

How to fix Jupyter notebook is not encoded in UTF-8

To fix a Jupyter notebook that is not encoded in UTF-8, you can try the following steps:

  1. Open the notebook file in a text editor, such as Sublime Text or Notepad++.
  2. Look for the line at the top of the file that says # coding: utf-8. This line specifies the encoding of the file. If the line is not present, add it to the top of the file.
  3. Save the file with the correct encoding. In Sublime Text, you can do this by going to File > Save with Encoding > UTF-8. In Notepad++, you can select UTF-8 from the Encoding dropdown menu in the Save As dialog box.
  4. Open the notebook in Jupyter. It should now be displayed correctly.

If the above steps do not resolve the issue, it is possible that the issue is caused by a problem with the notebook itself, rather than the encoding. In this case, you may need to fix any invalid characters or syntax errors in the notebook in order to get it to display correctly.

When opening a file gives you is not encoded in UTF-8 error

If a file that you are opening in Jupyter gives you a is not encoded in UTF-8 error, there may be a number of reasons why including a corrupt file.

is not encoded in UTF-8 when opening a zip file in Jupyter

You maybe find the following threads useful

  1. Error! blahfile is not UTF-8 encoded
  2. Error when trying to open a zip file in Jupyter

Error! (file) is not UTF-8 encoded when Opening a PDF in Jupyter

This is a known issue and has been discussed here in the Jupyter community