Bug report - python anki module circular import

My python version is 3.11.2 and my OS is Debian.

I installed the anki module using:
pip install anki

When running this code:

from anki.importing.apkg import AnkiPackageImporter

apkg_path = "/home/username/Downloads/test.apkg"
importer = AnkiPackageImporter(apkg_path)

I am getting this error:
ImportError: cannot import name 'NotetypeDict' from partially initialized module 'anki.models' (most likely due to a circular import)

I believe this is a bug, though I may be wrong.

It’s a bug. I sent a fix:

Note that you’ll need to add this before .run() for the code to work:

from anki.lang import set_lang


But I recommend using the new importing API instead. See an example here:

Thank you very much!

I am now using this code:

from anki.collection import ImportAnkiPackageRequest, Collection

collection = Collection("/home/username/.var/app/net.ankiweb.Anki/data/Anki2/User 1/collection.anki2")

And it works perfectly! :+1: