cfculhane / AnkiOCR

Anki Addon to create searchable text from images in notes, using Tesseract OCR
MIT License
17 stars 5 forks source link

Error While Processing New Notes #27

Closed Kona61 closed 3 years ago

Kona61 commented 3 years ago

Hello! Was just trying to convert some notes and get this error. Not very proficient with coding or reading our error logs, so I figured I'd put it here in case there's an issue or anybody can help me out.

Cancelled OCR processing with message :

['Traceback (most recent call last):\n', ' File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/gui.py", line 58, in on_run_ocr\n ocr.run_ocr_on_notes(note_ids=selected_nids)\n', ' File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/ocr.py", line 308, in run_ocr_on_notes\n notes_query = self.run_ocr_on_query(note_ids=note_ids)\n', ' File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/ocr.py", line 278, in run_ocr_on_query\n raw_results = self._ocr_batch_process(batched_txts=batched_txts)\n', ' File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/ocr.py", line 96, in _ocr_batch_process\n raw_results[batched_img_txt] = future.result()\n', ' File "concurrent/futures/_base.py", line 432, in result\n', ' File "concurrent/futures/_base.py", line 388, in __get_result\n', ' File "concurrent/futures/thread.py", line 57, in run\n', ' File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/ocr.py", line 264, in _ocr_img\n return pytesseract.image_to_string(str(img_pth), lang="+".join(languages or ["eng"]),\n', ' File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/_vendor/pytesseract/pytesseract.py", line 368, in image_to_string\n return {\n', ' File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/_vendor/pytesseract/pytesseract.py", line 371, in \n Output.STRING: lambda: run_and_get_output(*args),\n', ' File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/_vendor/pytesseract/pytesseract.py", line 280, in run_and_get_output\n run_tesseract(**kwargs)\n', ' File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/_vendor/pytesseract/pytesseract.py", line 257, in run_tesseract\n raise TesseractError(proc.returncode, get_errors(error_string))\n', "450181164._vendor.pytesseract.pytesseract.TesseractError: (-6, 'dyld: Library not loaded: ../../../leptonica/1.80.0/lib/liblept.5.dylib Referenced from: /Users/joshl/Library/Application Support/Anki2/addons21/450181164/deps/mac/tesseract/4.1.1/bin/tesseract Reason: image not found')\n"]

cfculhane commented 3 years ago

Hi there, thanks for the bug report, this actually is useful (if badly formatted - I'll fix that in the next release to make it easier to read/copy!). I'll have a quick look today to see if its an easy fix.

The main gist of the error message is the final line - "Reason: image not found", which means it tried to process an image that doesn't exist. Have you narrowed down which card is causing the problem? If so, it'd be great to see if the image DOES actually exist, cause if it does then I have a bug in my code somewhere :) If the image doesn't exist and shows up as a broken image symbol, that's fine too, I need to modify the plugin so that it handles missing images more gracefully.

cfculhane commented 3 years ago

image

I've tried to make a card with an image and then delete the image, and it turns out it already checks for missing images, and shows a warning. If you could verify whether or not the image exists in the card, that would be great!

Kona61 commented 3 years ago

Yea, it does it for all card, or even just 1 if I select it. I don't have any cards that are missing media, nor is there any extra media.

On Wed, Sep 15, 2021 at 3:09 PM Chris Culhane @.***> wrote:

[image: image] https://user-images.githubusercontent.com/40076371/133516463-6a8705d6-ee63-45c0-a65f-ca97ee2ffe2a.png

I've tried to make a card with an image and then delete the image, and it turns out it already checks for missing images, and shows a warning. If you could verify whether or not the image exists in the card, that would be great!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cfculhane/AnkiOCR/issues/27#issuecomment-920418254, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVUVJ5JFK5TXWKHVCBTE7EDUCEKSZANCNFSM5EC35GSQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

cfculhane commented 3 years ago

OK interesting, are you able to show me an example card and its path to its image? Like so:

image

And then if you go to the editor and press Control-Shift-X (or Command-Shift-X on Mac) you should see the raw HTML of the card like so:

image

You can paste images directly into the Github comment

Kona61 commented 3 years ago

Screen Shot 2021-09-16 at 1 16 07 PM

So, same error for a different car, basically.

cfculhane commented 3 years ago

Thanks, and which directory is that image in? Does it display properly in the card preview? Still can't see anything obviously wrong :/

cfculhane commented 3 years ago

Attempted a fix - https://github.com/cfculhane/AnkiOCR/releases/tag/V0.6.1 , please restart anki and check for updates of the plugin and try again :)

Kona61 commented 3 years ago

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 on the add-on support site. Debug info: Anki 2.1.47 (dc156f34) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2 Platform: Mac 10.16 Flags: frz=True ao=True sv=3 Add-ons, last update check: 2021-09-17 09:22:53 Add-ons possibly involved: ⁨AnkiOCR⁩

Caught exception: Traceback (most recent call last): File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/gui.py", line 58, in on_run_ocr ocr.run_ocr_on_notes(note_ids=selected_nids) File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/ocr.py", line 308, in run_ocr_on_notes notes_query = self.run_ocr_on_query(note_ids=note_ids) File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/ocr.py", line 278, in run_ocr_on_query raw_results = self._ocr_batch_process(batched_txts=batched_txts) File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/ocr.py", line 96, in _ocr_batch_process raw_results[batched_img_txt] = future.result() File "concurrent/futures/_base.py", line 432, in result File "concurrent/futures/_base.py", line 388, in __get_result File "concurrent/futures/thread.py", line 57, in run File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/ocr.py", line 264, in _ocr_img return pytesseract.image_to_string(str(img_pth), lang="+".join(languages or ["eng"]), File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/_vendor/pytesseract/pytesseract.py", line 368, in image_to_string return { File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/_vendor/pytesseract/pytesseract.py", line 371, in Output.STRING: lambda: run_and_get_output(*args), File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/_vendor/pytesseract/pytesseract.py", line 280, in run_and_get_output run_tesseract(**kwargs) File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/_vendor/pytesseract/pytesseract.py", line 257, in run_tesseract raise TesseractError(proc.returncode, get_errors(error_string)) 450181164._vendor.pytesseract.pytesseract.TesseractError: (-6, 'dyld: Library not loaded: ../../../leptonica/1.80.0/lib/liblept.5.dylib Referenced from: /Users/joshl/Library/Application Support/Anki2/addons21/450181164/deps/mac/tesseract/4.1.1/bin/tesseract Reason: image not found')

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/gui.py", line 124, in act_run_ocr.triggered.connect(lambda b=browser: on_run_ocr(browser)) File "/Users/joshl/Library/Application Support/Anki2/addons21/450181164/gui.py", line 75, in on_run_ocr from anki_ocr import version as anki_ocr_version ModuleNotFoundError: No module named 'anki_ocr'

Kona61 commented 3 years ago

Still having some issues. I really appreciate the effort you're making!

cfculhane commented 3 years ago

Ahh i stuffed something up in the release, but the old error is still occurring. One question - Do you have GIMP or ImageMagick installed on your mac? Or do you have Homebrew installed? Looks like a similar thing is happening to some other people.

cfculhane commented 3 years ago

I figured this out after many hours this morning!! Pushing update now

cfculhane commented 3 years ago

Fixed in https://github.com/cfculhane/AnkiOCR/releases/tag/V0.7.0 , please reopen if you have any further issues with this

cfculhane commented 3 years ago

EDIT: Ignore the below, have pushed a new release

Unfortunately I'm having some issues uploading the update - https://forums.ankiweb.net/t/connection-reset-during-large-upload-to-ankiweb/13460

I'll update this as soon as possible. For now you can remove your currently installed addon, download the .ankiaddon file from here : https://github.com/cfculhane/AnkiOCR/releases/tag/V0.7.0 and use that instead

Kona61 commented 3 years ago

Awesome! It works! Thanks a ton.

Perfect timing too lol. Will help me search my cards for untagged Image Occlusion cards before I get crucified on my test on Friday :D.

cfculhane commented 3 years ago

No worries, it affected all users of the addon on Mac's so it was worth sorting out, just a bit of brain teaser. Good luck for your test, fixing this was great procrastination from my research project ;)