kaegi / MorphMan

Anki plugin that reorders language cards based on the words you know
Other
261 stars 66 forks source link

MorphMan doesn't work with PyQt5 anymore #286

Open MNastri opened 1 year ago

MNastri commented 1 year ago

I got the message below after updating MorphMan:

Error

An add-on you installed failed to load. If problems persist, please go to the Tools>Add-ons menu, and disable or delete the add-on.

When loading '⁨MorphMan for Anki 21⁩': ⁨Traceback (most recent call last): File "aqt.addons", line 247, in loadAddons File "C:\Users\marce\AppData\Roaming\Anki2\addons21\900801631__init__.py", line 2, in from PyQt6.QtWidgets import * ModuleNotFoundError: No module named 'PyQt6'

I read that support for PyQt6 was just added, but I'm confused if PyQt5 was dropped by mistake or not.

MNastri commented 1 year ago

About Anki Debug Info

Anki 2.1.56 (07fd88dd) Python 3.9.15 Qt 5.15.2 PyQt 5.15.5
Platform: Windows-10-10.0.22621
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2023-01-13 16:20:50

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
'' ['slackers_delight', 0, 'None', '']
Auto Ease Factor ['1672712021', 2021-03-21T15:11, 'None', '']
Autosync 21 ['1726633659', 2019-03-08T20:58, 'None', '']
Deck name in title 21 ['699175524', 2019-05-31T22:05, 'None', '']
Highlight Search Results in the Browser ['225180905', 2021-03-10T14:06, 'None', '']
Mini Format Pack ['295889520', 2018-07-24T14:45, 'None', '']
Minimize to tray ['85158043', 2022-04-30T14:57, 'None', '']
Review Heatmap ['1771074083', 2022-06-29T22:43, 'None', '']
Searching PDF Reading  Note-Taking in Add Dialog ['1781298089', 2022-08-15T04:22, 'None', mod]
Syntax Highlighting for Code ['1463041493', 2018-10-06T22:31, 'None', '']
avgEase for Anki  2141 ['1129477042', 2021-06-27T08:58, 'None', '']
load balancer ['1417170896', 2020-08-05T20:58, 'None', '']

===IDs of active AnkiWeb add-ons===
1129477042 1417170896 1463041493 1672712021 1726633659 1771074083 1781298089 225180905 295889520 699175524 85158043

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Incremental Reading v4103 ['935264945', 2019-04-21T09:54, 'None', '']
MorphMan for Anki 21 ['900801631', 2023-01-10T17:01, 'None', '']
landonepps commented 1 year ago

It was not intentional. I'll update it to add back Qt5 support.

Out of curiosity, why are you using the Qt5 release of Anki? I thought the Qt6 version had backward compatibility with Qt5 for addons.

MNastri commented 1 year ago

Thank you!

To answer your question: I was not aware of that backwards compatibility. I have not read into this update yet and was afraid that moving to Qt6 would break everything but now I know. Thank you a second time 🙂

galantra commented 1 year ago

https://docs.ankiweb.net/platform/windows/installing.html?highlight=qt6#qt5-vs-qt6

Some add-ons currently only work with the Qt5 version.

I have experienced myself that some add-ons don't work anymore when I use Qt6

quietmansoath commented 1 year ago

It was not intentional. I'll update it to add back Qt5 support.

Out of curiosity, why are you using the Qt5 release of Anki? I thought the Qt6 version had backward compatibility with Qt5 for addons.

@landonepps, I am also having this issue. Currently using: Anki 2.1.54 (b6a7760c) Python 3.9.7 Qt 5.15.2 PyQt 5.15.5 Platform: Windows 10

Does this mean I should upgrade to the Qt6 version for now? I just downloaded the addon as-is from the anki add-ons page since it didn't seem like there was a release on the github page.

quietmansoath commented 1 year ago

If anyone comes to see this, yes, you need to upgrade to Qt6. I also upgraded to Anki 2.1.58 when doing so but it's working now.

rameauv commented 1 year ago

Shouldn't we be using "aqt.qt" instead of directly using "PyQt6" or "PyQt6"? Like in the anki plugin doc. https://addon-docs.ankiweb.net/qt.html

rameauv commented 1 year ago

We could probably support both qt5 and qt6 at the same time by doing that way. What do you think?

rameauv commented 1 year ago

I did a POC to see if this would work. Seems fine. If you wanna take a look. https://github.com/rameauv/MorphMan/commit/03e3318a4963716b2eb499d2182c805c920c3ff6

landonepps commented 1 year ago

Using aqt.qt, which handles backward compatibility, is the correct solution here. I've been distracted by other projects lately so I haven't had time to make the change. @rameauv Are you able to make a PR for this? If not, I can make the change in a day or two.

FYI, looking at the generated python files in https://github.com/rameauv/MorphMan/commit/03e3318a4963716b2eb499d2182c805c920c3ff6, it seems like your line endings are messed up.

rameauv commented 1 year ago

I'll refactor this and make a pr 👌

rameauv commented 1 year ago

Should I start from the master branch?

landonepps commented 1 year ago

I merged your changes to master, but unfortunately it's not true backwards compatibility. The auto-generated UI files will need to be manually updated to use aqt's compatibility layer. We'll probably have to write a script to generate it for PyQt6 and then patch it for backwards compatibility.

What addons are people using that don't support PyQt6?

rameauv commented 1 year ago

Yes exact. As long as anki qt6 support qt5 addons with the compatibility mode enabled by default it should work.

landonepps commented 1 year ago

If someone who uses the Qt5 version of Anki could test the lastest AnkiWeb version of MorphMan, I'd really appreciate it. The latest GitHub release works, too. https://github.com/kaegi/MorphMan/releases/tag/v5.0-qt6-alpha.4

I believe it should now be backwards compatible with Qt5. Please let us know here if you're still experiencing issues.