mmaaz-git / anki-pasteOCR

Addon for flashcard program Anki to paste images as text using Tesseract OCR.
GNU General Public License v3.0
3 stars 2 forks source link

Error on Install in Anki 23.10.1 (fac9e0ee) #6

Open xXWarMachineRoXx opened 10 months ago

xXWarMachineRoXx commented 10 months ago

Issue Summary

Anki encounters an error related to the 'pasteOCR' add-on, preventing normal functionality. When attempting to start Anki, the application prompts an error message advising to start Anki while holding down the shift key. The stack trace indicates an attribute error involving 'QKeySequence.NativeText' in the 'pasteOCR' add-on.

Environment

Error Dump

Error: An error occurred. Please start Anki while holding down the shift key...

Stack Trace

Caught exception:
Traceback (most recent call last):
  File "aqt.webview", line 50, in cmd
  ...
  File "C:\Users\_USER_\AppData\Roaming\Anki2\addons21\1746010116\__init__.py", line 34, in addMyButton
    keyStr = key.toString(QKeySequence.NativeText)
AttributeError: type object 'QKeySequence' has no attribute 'NativeText'

Steps to Replicate

  1. Install the add-on 'pasteOCR' from AnkiWeb.
  2. Start Anki.

Notes

thiotepamoa commented 10 months ago

I have the same issue.. I've tinkered around and this is one of the debugging logs:

Anki 23.12.1 (1a1d4d54) (ao) Python 3.9.15 Qt 6.5.3 PyQt 6.5.3 Platform: macOS-14.0-arm64-arm-64bit

Traceback (most recent call last): File "aqt.main", line 1237, in onAddCard File "aqt", line 136, in open File "aqt.addcards", line 51, in init File "aqt.addcards", line 78, in setupEditor File "aqt.editor", line 143, in init File "decorator", line 232, in fun File "anki.hooks", line 89, in decorator_wrapper File "anki.hooks", line 80, in repl File "aqt.editor", line 196, in setupWeb File "anki.hooks", line 45, in runFilter File "/Users/AnkiMan/Library/Application Support/Anki2/addons21/1746010116/init.py", line 34, in addMyButton keyStr = key.toString(QKeySequence.NativeText) AttributeError: type object 'QKeySequence' has no attribute 'NativeText'

xXWarMachineRoXx commented 10 months ago

keyStr = key.toString(QKeySequence.NativeText) AttributeError: type object 'QKeySequence' has no attribute 'NativeText'

keyStr = key.toString(QKeySequence.NativeText)

That seems to be the problem

PS: Also i noticed your using a mac, right?

thiotepamoa commented 10 months ago

Yes.

I'm not too computer savvy; how would I go about fixing this?

This only occurred after I updated Anki

jack2game commented 9 months ago

There is a potential fix here: https://forums.ankiweb.net/t/pasteocr-adds-on-not-working/40098/3

Basically this particular error at line 34 of __init__.py can be fixed by changing

QKeySequence.NativeText to QKeySequence.SequenceFormat.NativeText and QKeySequence.PortableText to QKeySequence.SequenceFormat.PortableText

xXWarMachineRoXx commented 9 months ago

@jack2game, seems like it.

I got the exact answer from chatgpt 4.

I'll try do a pull request and try and fix it

xXWarMachineRoXx commented 9 months ago

Yes.

I'm not too computer savvy; how would I go about fixing this?

This only occurred after I updated Anki

@thiotepamoa clone the repo and install on ur computer and make changes

After that push those changes to fix this

You would have to have moderate level pyhton experience and atleast beginner level anki / codebase knowledge

jack2game commented 9 months ago

I ready made the PR

xXWarMachineRoXx commented 9 months ago

@jack2game #7 seems to address this issue will be merged when @mmaaz-git works on it