Stvad / CrowdAnki

Plugin for Anki SRS designed to facilitate cooperation on creation of notes and decks.
MIT License
533 stars 44 forks source link

Anki 2.1.50 throws exception on crowdanki imports on macOS Monterey 12.3.1 (AttributeError: 'AnkiQt' object has no attribute 'backup') #166

Closed schwa closed 2 years ago

schwa commented 2 years ago

Importing a crowdanki document on Anki 2.1.50 (File > Crowd Anki Import from Disk) causes an exception to be thrown the import to fail. Failure occurs with my existing Anki Profile or with a new testing Anki Profile. It fails with a variety of crowdanki documents.

Upgrading the latest crowdanki via the Anki menu,

Downgrading to Anki 2.1.49 works around the error.

Here's the copied error:

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue to the add-on author.
Debug info:
Anki 2.1.50 (26d40c3a) Python 3.9.7 Qt 6.2.3 PyQt 6.2.3
Platform: Mac 12.3.1
Flags: frz=True ao=True sv=?
Add-ons, last update check: 2022-04-23 16:03:32
Add-ons possibly involved: ⁨CrowdAnki JSON exportimport Edit history Collaborate on deck creation⁩

Caught exception:
Traceback (most recent call last):
  File "/Users/schwa/Library/Application Support/Anki2/addons21/1788670778/anki/ui/action_vendor.py", line 31, in <lambda>
    lambda: AnkiJsonImporter.import_deck(self.window.col, self.directory_vendor))
  File "/Users/schwa/Library/Application Support/Anki2/addons21/1788670778/importer/anki_importer.py", line 114, in import_deck
    AnkiJsonImporter.import_deck_from_path(collection, Path(directory_path))
  File "/Users/schwa/Library/Application Support/Anki2/addons21/1788670778/importer/anki_importer.py", line 103, in import_deck_from_path
    if importer.load_deck(directory_path):
  File "/Users/schwa/Library/Application Support/Anki2/addons21/1788670778/importer/anki_importer.py", line 37, in load_deck
    aqt.mw.backup()
AttributeError: 'AnkiQt' object has no attribute 'backup'
aplaice commented 2 years ago

Thanks very much for the bug report!

I expect that this is linked to the backup changes in Anki in PR 1728. We probably can now just use aqt.mw.create_backup_now. I'll try to look into this in greater detail in a couple of days' time.

(I had tested the Anki 2.1.50 beta a while ago, hadn't encountered any critical issues at the time and didn't check again. :/)

schwa commented 2 years ago

Sticking to .49 as a temporary workaround is fine.

boydkelly commented 2 years ago

exact same error on: Debug info:
Anki 2.1.51 (cf78a555) Python 3.10.4 Qt 5.15.2 PyQt 5.15.6
Platform: Linux

boydkelly commented 2 years ago

I tried to test this and copied the crowd_anki directory (from the branch above) into my addons2. But when I start Anki 2.1.51 or 2.1.52 the addon does not seem to be available. After restarting Anki the menu items are not available, and going to tools addons the addon is visible but config button is also not available. Did I have to do anything further than copy the directory? Thanks for all your work on this!

aplaice commented 2 years ago

Did I have to do anything further than copy the directory?

You need the dependencies in dist/. You can generate them by running fetch_dependencies.sh (basically a pip install into dist/), or more easily/faster by copying them from the dist/ from CrowdAnki from AnkiWeb or from the latest release (the dependencies haven't changed since the v0.9.1 release, so dist/ will be the same.

(This is necessary because Anki doesn't have any good mechanism for managing dependencies.)


Edit: Also, you need to rename the directory from crowd_anki to something else (e.g. crowd-anki) — otherwise main won't be imported.

schwa commented 2 years ago

Awesome. Thank you