Repository navigation
Open
Milestone
Description
While working in ipython notebook, I make reboot of my OS X by shotdown button. After restart, I saw error upon attempt to open .ipynb files by ipython notebook. This is the first error that I've get:
[E 10:42:13.434 NotebookApp] Unhandled error in API request
Traceback (most recent call last):
File "/Users/cnst/anaconda/envs/py27/lib/python2.7/site-packages/notebook/base/handlers.py", line 436, in wrapper
result = yield gen.maybe_future(method(self, *args, **kwargs))
File "/Users/cnst/anaconda/envs/py27/lib/python2.7/site-packages/tornado/gen.py", line 870, in run
value = future.result()
File "/Users/cnst/anaconda/envs/py27/lib/python2.7/site-packages/tornado/concurrent.py", line 215, in result
raise_exc_info(self._exc_info)
File "/Users/cnst/anaconda/envs/py27/lib/python2.7/site-packages/tornado/gen.py", line 230, in wrapper
yielded = next(result)
File "/Users/cnst/anaconda/envs/py27/lib/python2.7/site-packages/notebook/services/contents/handlers.py", line 126, in get
path=path, type=type, format=format, content=content,
File "/Users/cnst/anaconda/envs/py27/lib/python2.7/site-packages/notebook/services/contents/filemanager.py", line 350, in get
model = self._notebook_model(path, content=content)
File "/Users/cnst/anaconda/envs/py27/lib/python2.7/site-packages/notebook/services/contents/filemanager.py", line 310, in _notebook_model
self.mark_trusted_cells(nb, path)
File "/Users/cnst/anaconda/envs/py27/lib/python2.7/site-packages/notebook/services/contents/manager.py", line 447, in mark_trusted_cells
trusted = self.notary.check_signature(nb)
File "/Users/cnst/anaconda/envs/py27/lib/python2.7/site-packages/nbformat/sign.py", line 220, in check_signature
if self.db is None:
File "/Users/cnst/anaconda/envs/py27/lib/python2.7/site-packages/traitlets/traitlets.py", line 439, in __get__
value = self._validate(obj, dynamic_default())
File "/Users/cnst/anaconda/envs/py27/lib/python2.7/site-packages/nbformat/sign.py", line 127, in _db_default
self.init_db(db)
File "/Users/cnst/anaconda/envs/py27/lib/python2.7/site-packages/nbformat/sign.py", line 139, in init_db
)""")
DatabaseError: database disk image is malformed
[E 10:42:13.438 NotebookApp] {
"Accept-Language": "en-US,en;q=0.8",
"Accept-Encoding": "gzip, deflate, sdch",
"Connection": "keep-alive",
"Accept": "application/json, text/javascript, */*; q=0.01",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36",
"Host": "localhost:8888",
"Referer": "http://localhost:8888/notebooks/assignment1/softmax.ipynb",
"X-Requested-With": "XMLHttpRequest"
}
I was looking for a solution and found suggestions of moving/deleting files in previous issues:
~/.ipython/profile_default/security/nbsignatures.db
and
~/.ipython/profile_default/history.sqlite
It didn't fix the problem.
After all, because ipython notebook comes with Anaconda distribution, I've tried to reinstall anaconda (erase ~/anaconda folder, and at second attempt erase it with ~/.ipython and ~/.jupyter directories).
Now I've got something like this:
[E 19:19:57.919 NotebookApp] Unhandled error in API request
Traceback (most recent call last):
File "/Users/cnst/anaconda/lib/python3.5/site-packages/traitlets/traitlets.py", line 432, 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 "/Users/cnst/anaconda/lib/python3.5/site-packages/notebook/base/handlers.py", line 436, in wrapper
result = yield gen.maybe_future(method(self, *args, **kwargs))
File "/Users/cnst/anaconda/lib/python3.5/site-packages/tornado/gen.py", line 870, in run
value = future.result()
File "/Users/cnst/anaconda/lib/python3.5/site-packages/tornado/concurrent.py", line 215, in result
raise_exc_info(self._exc_info)
File "<string>", line 3, in raise_exc_info
File "/Users/cnst/anaconda/lib/python3.5/site-packages/tornado/gen.py", line 230, in wrapper
yielded = next(result)
File "/Users/cnst/anaconda/lib/python3.5/site-packages/notebook/services/contents/handlers.py", line 126, in get
path=path, type=type, format=format, content=content,
File "/Users/cnst/anaconda/lib/python3.5/site-packages/notebook/services/contents/filemanager.py", line 350, in get
model = self._notebook_model(path, content=content)
File "/Users/cnst/anaconda/lib/python3.5/site-packages/notebook/services/contents/filemanager.py", line 310, in _notebook_model
self.mark_trusted_cells(nb, path)
File "/Users/cnst/anaconda/lib/python3.5/site-packages/notebook/services/contents/manager.py", line 447, in mark_trusted_cells
trusted = self.notary.check_signature(nb)
File "/Users/cnst/anaconda/lib/python3.5/site-packages/nbformat/sign.py", line 220, in check_signature
if self.db is None:
File "/Users/cnst/anaconda/lib/python3.5/site-packages/traitlets/traitlets.py", line 439, in __get__
value = self._validate(obj, dynamic_default())
File "/Users/cnst/anaconda/lib/python3.5/site-packages/nbformat/sign.py", line 127, in _db_default
self.init_db(db)
File "/Users/cnst/anaconda/lib/python3.5/site-packages/nbformat/sign.py", line 139, in init_db
)""")
sqlite3.DatabaseError: database disk image is malformed
[E 19:19:57.928 NotebookApp] {
"Connection": "keep-alive",
"Accept-Encoding": "gzip, deflate, sdch",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36",
"Host": "localhost:8888",
"Accept": "application/json, text/javascript, */*; q=0.01",
"X-Requested-With": "XMLHttpRequest",
"Referer": "http://localhost:8888/notebooks/notebooks/neuralnetworks/assignment1/softmax.ipynb",
"Accept-Language": "en-US,en;q=0.8"
}
And after complete reinstalling anaconda with folders deletion folder
~/.ipython/profile_default/security
is empty.
I didn't understand what I should do in this situation. Maybe you can help.
Metadata
Metadata
Assignees
Labels
No labels
Activity
Carreau commentedon Nov 23, 2015
try to
rm $(jupyter --data-dir)/nbsignatures.db, config and cached files are not in~/.ipythonanymore.We should still catch that error and delete the signature files though.
jstarsky commentedon Dec 31, 2015
I have the same problem. Is somebody who can help me?.

thatdeep commentedon Dec 31, 2015
Did you try Carreau's suggestion? Seems that It helped me.
jamesfe commentedon Jan 5, 2016
@Carreau what is a good place in the code to start looking to fix this? I'd probably start looking wherever the entry point to load files is. If I can catch the exception there, I can print something more worthwhile, then attempt to rebuild the DB. If there's already functionality to create the DB, I can use that to recreate the DB for the user.
For tests - I will provide an invalid DB file and ensure it warns the user and creates a new DB.
Carreau commentedon Jan 5, 2016
you likely want to look there and if you get a
sqlite3.DatabaseError: database disk image is malformedmove the file over and create a new one.jamesfe commentedon Jan 5, 2016
Thanks! I'll work on this in the evening today if I have time.
Carreau commentedon Jan 5, 2016
No hurry, feel free to ask if you need help,and feel free to submit early PRs for feedback !
adalca commentedon May 20, 2017
In case this is helpful to anyone: I continued having this issue even after removing the mentioned files.
It turns out I was running jupyters on two separate computers that were accessing the same db files on a shared NFS (i.e. ~/.local was on NFS), resulting in some sort of collision. I linked ~/.local to local dirs, eliminating the problem (or so it seems so far)
takluyver commentedon May 22, 2017
Yeah, there are known issues with SQLite on NFS that we can't resolve. We've made the signature store pluggable so you can use some system other than SQLite to store the signatures, but we don't have anything better to plug in as the default.
riteshgane commentedon Apr 30, 2020
I have this error - sqlite3.DatabaseError: database disk image is malformed.
I have moved the history.sqlite file.
how to create new sqlite file in profile_default folder.