Why my code can not work?

I copy down the code from anki addon writing guide but it doesn’t work at all.
Here is my code:
from aqt.qt import *
from aqt.utils import getText, tooltip,showWarning,showInfo,getOnlyText
from aqt import mw
from anki.hooks import addHook
from aqt.deckbrowser import DeckBrowser
from anki.hooks import runHook
from anki.decks import DeckManager
from anki.tags import TagManager
import pickle
import sqlite3

def getCardIdByTag(tag):
tag = " marked "
cardIdList = mw.col.find_cards(“tag:%s”,tag)

However,I get a bug information, which I show below.

Caught exception:
Traceback (most recent call last):
File “C:\Users\woodsonchild\AppData\Roaming\Anki2\addons21\saveid_init_.py”, line 58, in getCardIdByTag
cardIdList = mw.col.find_cards(“tag:%s”,tag)
AttributeError: ‘_Collection’ object has no attribute ‘find_card
Why I get this bug?

You need to update to a more recent Anki.

My anki version is 2.1.22.It seems not a problem about version.

That example requires a more recent Anki.

1 Like