Can't Use the Add-on in Anki via PyPi

I have installed Anki on ArchLinux (Arm) via PyPi properly, but the add-on fails to work.
I’ve tried mutliple Anki versions (24.06.2, 24.04.1, 23.10). I had no such issue a while earlier and everything worked properly in the same environmemt.

Debug Info:

Anki 23.12.1 (1a1d4d54) (src) (ao)
Python 3.12.3 Qt 6.7.1 PyQt 6.7.0
Platform: Linux-6.2.1-PRoot-Distro-aarch64-with-glibc2.39

When loading AnkiHub:
Traceback (most recent call last):
  File "/root/pyenv/lib/python3.12/site-packages/aqt/addons.py", line 245, in loadAddons
    __import__(addon.dir_name)
  File "/root/.local/share/Anki2/addons21/1322529746/__init__.py", line 28, in <module>
    from . import entry_point
  File "/root/.local/share/Anki2/addons21/1322529746/entry_point.py", line 10, in <module>
    from .db import ankihub_db
  File "/root/.local/share/Anki2/addons21/1322529746/db/__init__.py", line 1, in <module>
    from .db import ankihub_db, execute_list_query_in_chunks, flat  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/share/Anki2/addons21/1322529746/db/db.py", line 38, in <module>
    from ..ankihub_client import Field, NoteInfo, suggestion_type_from_str
  File "/root/.local/share/Anki2/addons21/1322529746/ankihub_client/__init__.py", line 6, in <module>
    from .ankihub_client import (  # noqa: F401
  File "/root/.local/share/Anki2/addons21/1322529746/ankihub_client/ankihub_client.py", line 44, in <module>
    from .models import (
  File "/root/.local/share/Anki2/addons21/1322529746/ankihub_client/models.py", line 14, in <module>
    from mashumaro.mixins.json import DataClassJSONMixin
  File "/root/.local/share/Anki2/addons21/1322529746/lib/mashumaro/mixins/json.py", line 14, in <module>
    class DataClassJSONMixin(DataClassDictMixin):
  File "/root/.local/share/Anki2/addons21/1322529746/lib/mashumaro/mixins/dict.py", line 21, in __init_subclass__
    compile_mixin_unpacker(cls, **builder_params["unpacker"])
  File "/root/.local/share/Anki2/addons21/1322529746/lib/mashumaro/core/meta/mixin.py", line 44, in compile_mixin_unpacker
    builder.add_unpack_method()
  File "/root/.local/share/Anki2/addons21/1322529746/lib/mashumaro/core/meta/builder.py", line 453, in add_unpack_method
    self._add_unpack_method_lines(method_name)
  File "/root/.local/share/Anki2/addons21/1322529746/lib/mashumaro/core/meta/builder.py", line 342, in _add_unpack_method_lines
    pre_deserialize = self.get_declared_hook(__PRE_DESERIALIZE__)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/share/Anki2/addons21/1322529746/lib/mashumaro/core/meta/builder.py", line 309, in get_declared_hook
    if not is_dataclass_dict_mixin(cls):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/share/Anki2/addons21/1322529746/lib/mashumaro/core/meta/helpers.py", line 367, in is_dataclass_dict_mixin
    return type_name(t) == DataClassDictMixinPath
           ^^^^^^^^^^^^
  File "/root/.local/share/Anki2/addons21/1322529746/lib/mashumaro/core/meta/helpers.py", line 150, in type_name
    elif is_generic(t) and not is_type_origin:
         ^^^^^^^^^^^^^
  File "/root/.local/share/Anki2/addons21/1322529746/lib/mashumaro/core/meta/helpers.py", line 223, in is_generic
    raise NotImplementedError
NotImplementedError

The add-on hasn’t been tested with Python versions higher than 3.9 (the one packaged with Anki).

1 Like

Turns out it works fine up to python3.11.2. Are there no plans to fix this? Most distros updated to python3.12.3, besides Anki Docs state that it should work with python3.9+.

Simply updating the add-on’s Python dependencies will probably solve this but we have to ensure the add-on still works with older Anki versions we currently support (2.1.56+). Very few users install Anki via PyPi and use it with their system’s Python version, so fixing this is low priority I’m afraid. We probably won’t look into it until it becomes a problem in Anki’s official binary packages.

1 Like

Is there any documentation about these dependencies?
I’ve also faced this in Alpine Linux, anki package (aarch64, testing). I have it running properly on Debian with python3.11.2; would it be safe to update to python3.12 when it’s released? (Normal Anki installation not via PyPi)

The dependencies are in the lib folder inside the add-on’s folder. The error is coming from mashumaro. Maybe replacing it with a newer version will make the add-on work.

That depends on whether Anki has incompatibilities with Python 3.12 (unlikely).