Anki crashes on sync/study/export

I’ve been using Anki and today started getting crashes that seem to be related to syncing, but are preventing me from studying too. Not sure if these are related to the problems others are having that may be related to a Windows 10 update or not.

The behavior is the same for the 64-bit and 32-bit versions of 2.1.29. I’m using the Chinese Support Redux 0140 add-on, and the results are the same when it is both enabled and disabled.

Whenever I start or try to quit Anki, I get the “Please use Tools>Check Database” window, and Anki crashes and disappears completely when I check database on “Checking Notes.”

When I try to study a deck, this comes up:

    Anki 2.1.29 (bbff62bf) Python 3.8.1 Qt 5.12.6 PyQt 5.12.3
Platform: Windows 10
Flags: frz=True ao=False sv=2
Add-ons, last update check: 2020-08-06 09:54:02

Caught exception:
Traceback (most recent call last):
File "aqt\webview.py", line 37, in cmd
File "aqt\webview.py", line 123, in _onCmd
File "aqt\webview.py", line 544, in _onBridgeCmd
File "aqt\overview.py", line 67, in _linkHandler
File "aqt\main.py", line 646, in moveToState
File "aqt\main.py", line 668, in _reviewState
File "aqt\reviewer.py", line 65, in show
File "aqt\reviewer.py", line 118, in nextCard
File "aqt\reviewer.py", line 183, in _showQuestion
File "lib\site-packages\anki\cards.py", line 113, in question
File "lib\site-packages\anki\cards.py", line 132, in render_output
File "lib\site-packages\anki\template.py", line 115, in from_existing_card
File "lib\site-packages\anki\cards.py", line 142, in note
File "lib\site-packages\anki\collection.py", line 309, in getNote
File "lib\site-packages\anki\notes.py", line 34, in __init__
File "lib\site-packages\anki\notes.py", line 42, in load
File "lib\site-packages\anki\notes.py", line 52, in _load_from_backend_note
File "lib\site-packages\anki\models.py", line 273, in fieldMap
TypeError: 'NoneType' object is not subscriptable

When syncing, this is the error:

    Anki 2.1.29 (bbff62bf) Python 3.8.1 Qt 5.12.6 PyQt 5.12.3
Platform: Windows 10
Flags: frz=True ao=False sv=2
Add-ons, last update check: 2020-08-06 09:54:02

Caught exception:
Traceback (most recent call last):
File "aqt\webview.py", line 37, in cmd
File "aqt\webview.py", line 123, in _onCmd
File "aqt\webview.py", line 544, in _onBridgeCmd
File "aqt\toolbar.py", line 171, in _linkHandler
File "aqt\toolbar.py", line 195, in _syncLinkHandler
File "aqt\main.py", line 883, in on_sync_button_clicked
File "aqt\main.py", line 895, in _sync_collection_and_media
File "aqt\sync.py", line 118, in sync_collection
File "aqt\main.py", line 892, in on_collection_sync_finished
File "aqt\main.py", line 684, in reset
File "aqt\main.py", line 646, in moveToState
File "aqt\main.py", line 668, in _reviewState
File "aqt\reviewer.py", line 65, in show
File "aqt\reviewer.py", line 118, in nextCard
File "aqt\reviewer.py", line 183, in _showQuestion
File "lib\site-packages\anki\cards.py", line 113, in question
File "lib\site-packages\anki\cards.py", line 132, in render_output
File "lib\site-packages\anki\template.py", line 115, in from_existing_card
File "lib\site-packages\anki\cards.py", line 142, in note
File "lib\site-packages\anki\collection.py", line 309, in getNote
File "lib\site-packages\anki\notes.py", line 34, in __init__
File "lib\site-packages\anki\notes.py", line 42, in load
File "lib\site-packages\anki\notes.py", line 52, in _load_from_backend_note
File "lib\site-packages\anki\models.py", line 273, in fieldMap
TypeError: 'NoneType' object is not subscriptable

I am unable to export a deck, too:

    Anki 2.1.29 (bbff62bf) Python 3.8.1 Qt 5.12.6 PyQt 5.12.3
Platform: Windows 10
Flags: frz=True ao=False sv=2
Add-ons, last update check: 2020-08-06 09:54:02

Caught exception:
Traceback (most recent call last):
File "aqt\taskman.py", line 87, in _on_closures_pending
File "aqt\taskman.py", line 59, in <lambda>
File "aqt\exporting.py", line 163, in on_done
File "concurrent\futures\_base.py", line 432, in result
File "concurrent\futures\_base.py", line 388, in __get_result
File "concurrent\futures\thread.py", line 57, in run
File "aqt\exporting.py", line 157, in do_export
File "lib\site-packages\anki\exporting.py", line 320, in exportInto
File "lib\site-packages\anki\exporting.py", line 328, in doExport
File "lib\site-packages\anki\exporting.py", line 261, in exportInto
File "lib\site-packages\anki\media.py", line 140, in filesInStr
File "lib\site-packages\anki\latex.py", line 70, in render_latex
File "lib\site-packages\anki\latex.py", line 85, in render_latex_returning_errors
AttributeError: 'NoneType' object has no attribute 'get'

I found an answer to a similar problem in a forum on another site that involved cutting and pasting the following into the debug console:

for d in mw.col.decks.decks.values():
if "conf" in d and isinstance(d['conf'], str):
d['conf'] = int(d['conf'])
mw.col.decks.save(d)

That didn’t fix the problem, and the result came back:

>>> for d in mw.col.decks.decks.values():
... if "conf" in d and isinstance(d['conf'], str):
... d['conf'] = int(d['conf'])
... mw.col.decks.save(d)
add-on should use methods on col.decks, not col.decks.decks dict

Is this some sort of deck corruption? Or is this the same problem others are having? Hope these outputs are helpful.

Would you mind exporting the collection with scheduling info, uploading it somewhere (eg gofile.io), and sharing the link with me in a private message? I’ll look into why check db is crashing and what is required to fix your collection.

The error is self-explanatory. You are trying to subscript an object which you think is a list or dict, but actually is None (i.e: the object has no value). This means that you tried to do:

None[something]

Here you attempted to index an object that doesn’t have that functionality. You might have noticed that the method sort() that only modify the list have no return value printed – they return the default None. This is a design principle for all mutable data structures in Python.

This ‘NoneType’ object is not subscriptable is the one thrown by python when you use the square bracket notation object[key] where an object doesn’t define the getitem method.