Ipython: IPython Notebook error: Error loading notebook

Created on 23 Jan 2016  路  8Comments  路  Source: ipython/ipython

Within the past few minutes, I have not been able to access any of the .ipynb files previously created with Python3.4. I go to the subdirectory with these files, enter

ipython3 notebook

When I click on a certain .ipynb file, I get the following error:

An unknown error occurred while loading this notebook. This version can load notebook formats v4 or earlier. See the server log for details.
[E 00:19:41.468 NotebookApp] Unhandled error in API request
    Traceback (most recent call last):
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/traitlets/traitlets.py", line 460, in get
        value = obj._trait_values[self.name]
    KeyError: 'db'
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/notebook/base/handlers.py", line 458, in wrapper
    result = yield gen.maybe_future(method(self, *args, **kwargs))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/tornado/gen.py", line 282, in wrapper
    yielded = next(result)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/notebook/services/contents/handlers.py", line 124, in get
    path=path, type=type, format=format, content=content,
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/notebook/services/contents/filemanager.py", line 354, in get
    model = self._notebook_model(path, content=content)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/notebook/services/contents/filemanager.py", line 314, in _notebook_model
    self.mark_trusted_cells(nb, path)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/notebook/services/contents/manager.py", line 447, in mark_trusted_cells
    trusted = self.notary.check_signature(nb)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/nbformat/sign.py", line 220, in check_signature
    if self.db is None:
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/traitlets/traitlets.py", line 488, in __get__
    return self.get(obj, cls)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/traitlets/traitlets.py", line 467, in get
    value = self._validate(obj, dynamic_default())
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/nbformat/sign.py", line 127, in _db_default
    self.init_db(db)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/nbformat/sign.py", line 139, in init_db
    )""")
sqlite3.DatabaseError: database disk image is malformed

How does one solve this issue?

Most helpful comment

The database of notebook signatures got corrupted. To move it out of the way:

cd $(jupyter --data-dir)
mv nbsignatures.db nbsignatures.db.bak   # Or just rm it - there's probably no use keeping the corrupt file

We're working on catching the error and doing this automatically in jupyter/nbformat#32.

Once you've done this, all notebooks will be untrusted again. That means that you may have to re-execute them, or manually trust them from the file menu, before some rich output will be displayed.

All 8 comments

The database of notebook signatures got corrupted. To move it out of the way:

cd $(jupyter --data-dir)
mv nbsignatures.db nbsignatures.db.bak   # Or just rm it - there's probably no use keeping the corrupt file

We're working on catching the error and doing this automatically in jupyter/nbformat#32.

Once you've done this, all notebooks will be untrusted again. That means that you may have to re-execute them, or manually trust them from the file menu, before some rich output will be displayed.

My problem was solved with

rm ~/Library/Jupyter/nbsignatures.db

Thanks

remove ~/.ipython/profile_default/history_sqlite

This helps for me.

@KnightOfTheMoonlight I think the file is called "history.sqlite" instead of "history_sqlite".

Check the available space in your working environment!!!
I had this error when the server had no space.

@takluyver I had similar issue and your suggestions did work. Thanks!

Check the available space in your working environment!!!
I had this error when the server had no space.

This was my problem too. Thanks for the tip! It worked!

First run the following in the terminal:
sudo jupyter notebook --allow-root

Then some URL will appear in the terminal, something like:

http://localhost:8888/?token=f2704ecba4c88716337f33e79e13335380e25382603afb80

Finally, copy and paste this URL in a new tab in your browser. Then the jupyter notebook will open in a new tab.

Cheers!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alvations picture alvations  路  4Comments

zhao-ji picture zhao-ji  路  4Comments

okomarov picture okomarov  路  3Comments

ederag picture ederag  路  3Comments

jakirkham picture jakirkham  路  4Comments