tvhong / incremental-reading

Anki add-on providing incremental reading features
https://ankiweb.net/shared/info/935264945
ISC License
33 stars 7 forks source link

[Anki 23.10 beta 6] No module named 'sip', 'PyQt5' #28

Closed khonkhortisan closed 1 year ago

khonkhortisan commented 1 year ago

Describe the bug

The Qt5 compatibility code is now off by default, which may break some add-ons that haven't been updated to support Qt6 in the last 2 years. If you find any have broken, please report the issues to the add-on author, and start Anki after setting the env var ENABLE_QT5_COMPAT to 1 to temporarily restore the compatibility code.

To Reproduce Steps to reproduce the behavior: . Go to '...' . Click on '....' . Scroll down to '....' . See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Specs (please complete the following information):

Additional context Add any other context about the problem here.

Error
Un complemento que has instalado ha fallado al cargarse. Si los problemas persisten, por favor ve a Herramientas> Menú de complementos o deshabilita este complemento.

Mientras cargando '⁨Incremental Reading v4118 unofficial clone⁩':
⁨Traceback (most recent call last):
  File "aqt.addons", line 239, in loadAddons
  File "C:\Users\Khonkhortisan\AppData\Roaming\Anki2\addons21\999215520\__init__.py", line 17, in <module>
    from .main import ReadingManager
  File "C:\Users\Khonkhortisan\AppData\Roaming\Anki2\addons21\999215520\main.py", line 26, in <module>
    import sip
ModuleNotFoundError: No module named 'sip'

main.py

try:
    from PyQt6 import sip
except ImportError:
    import sip

about.py

#from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QLabel, QVBoxLayout
try:
    from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QLabel, QVBoxLayout
except ImportError:
    from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QLabel, QVBoxLayout

gui.py

try:
    from PyQt6.QtCore import Qt
    from PyQt6.QtGui import QFont
    from PyQt6.QtWidgets import (
        QButtonGroup,
        QCheckBox,
        QComboBox,
        QDialog,
        QDialogButtonBox,
        QGroupBox,
        QHBoxLayout,
        QKeySequenceEdit,
        QLabel,
        QLineEdit,
        QPushButton,
        QRadioButton,
        QTabWidget,
        QVBoxLayout,
        QWidget,
    )
except ImportError:
    from PyQt5.QtCore import Qt
    from PyQt5.QtGui import QFont
    from PyQt5.QtWidgets import (
        QButtonGroup,
        QCheckBox,
        QComboBox,
        QDialog,
        QDialogButtonBox,
        QGroupBox,
        QHBoxLayout,
        QKeySequenceEdit,
        QLabel,
        QLineEdit,
        QPushButton,
        QRadioButton,
        QTabWidget,
        QVBoxLayout,
        QWidget,
    )

util.py

#from PyQt5.QtCore import Qt
#from PyQt5.QtGui import QKeySequence
#from PyQt5.QtWidgets import QAction, QMenu, QSpinBox
try:
    from PyQt6.QtCore import Qt
    from PyQt6.QtGui import QKeySequence
    from PyQt6.QtWidgets import QMenu, QSpinBox
    from PyQt6.QtGui import QAction
except ImportError:
    from PyQt5.QtCore import Qt
    from PyQt5.QtGui import QKeySequence
    from PyQt5.QtWidgets import QAction, QMenu, QSpinBox

importer.py

try:
    from PyQt6.QtCore import Qt
    from PyQt6.QtWidgets import (
        QAbstractItemView,
        QDialog,
        QDialogButtonBox,
        QListWidget,
        QListWidgetItem,
        QVBoxLayout,
    )
except ImportError:
    from PyQt5.QtCore import Qt
    from PyQt5.QtWidgets import (
        QAbstractItemView,
        QDialog,
        QDialogButtonBox,
        QListWidget,
        QListWidgetItem,
        QVBoxLayout,
    )

schedule.py

try:
    from PyQt6.QtCore import Qt
    from PyQt6.QtWidgets import (
        QAbstractItemView,
        QDialog,
        QDialogButtonBox,
        QHBoxLayout,
        QListWidget,
        QListWidgetItem,
        QPushButton,
        QVBoxLayout,
    )
except ImportError:
    from PyQt5.QtCore import Qt
    from PyQt5.QtWidgets import (
        QAbstractItemView,
        QDialog,
        QDialogButtonBox,
        QHBoxLayout,
        QListWidget,
        QListWidgetItem,
        QPushButton,
        QVBoxLayout,
    )
tvhong commented 1 year ago

Thank you for reporting!

Guess this will start breaking from 23.10 huh. I'll see if I got some time to clean this up. It's time to migrate to PyQt6.

https://github.com/ankitects/anki/releases/tag/23.10beta6

tvhong commented 1 year ago

@khonkhortisan I have added the changes that you suggested and got the plugin to load in Anki 23.10 beta 6. Thanks again for reporting and showing me how to fix it!

I'll release a new version shortly.