I recently was quite surprised to see the following errors when trying to open Anki:
Your collection is corrupt. Please create a new profile, then see the manual for how to restore from an automatic backup.
Debug info:
Traceback (most recent call last):
File "/usr/share/anki/aqt/main.py", line 269, in loadCollection
self.col = Collection(cpath, log=True)
File "/usr/share/anki/anki/storage.py", line 32, in Collection
ver = _upgradeSchema(db)
File "/usr/share/anki/anki/storage.py", line 55, in _upgradeSchema
ver = db.scalar("select ver from col")
File "/usr/share/anki/anki/db.py", line 72, in scalar
res = self.execute(*a, **kw).fetchone()
File "/usr/share/anki/anki/db.py", line 39, in execute
res = self._db.execute(sql, a)
OperationalError: disk I/O error
as well as:
An error occurred. It may have been caused by a harmless bug,
or your deck may have a problem.
To confirm it's not a problem with your deck, please run Tools > Check Database.
If that doesn't fix the problem, please copy the following
into a bug report:
Traceback (most recent call last):
File "/usr/share/anki/aqt/progress.py", line 69, in handler
func()
File "/usr/share/anki/aqt/main.py", line 110, in setupProfile
self.loadProfile()
File "/usr/share/anki/aqt/main.py", line 234, in loadProfile
self.onSync(auto=True)
File "/usr/share/anki/aqt/main.py", line 598, in onSync
self.loadCollection()
File "/usr/share/anki/anki/hooks.py", line 55, in repl
old(*args, **kwargs)
File "/usr/share/anki/anki/hooks.py", line 55, in repl
old(*args, **kwargs)
File "/usr/share/anki/aqt/main.py", line 278, in loadCollection
self.unloadProfile()
File "/usr/share/anki/aqt/main.py", line 257, in unloadProfile
self.pm.save()
File "/usr/share/anki/aqt/profiles.py", line 122, in save
self.name.encode("utf8"))
File "/usr/share/anki/anki/db.py", line 39, in execute
res = self._db.execute(sql, a)
sqlite3.OperationalError: unable to open database file
This error seems to be caused after Anki crashed while accessing the database, such that the “accessing file” status is not removed. Luckily though, the problem can be solved simply by copying the database to a new file, e.g. run:
Some other approaches for unlocking the database (most of which didn’t work for me) can be found at stackoverflow.