cfculhane / AnkiOCR

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

Error #33

Open yzy1228682367 opened 2 years ago

yzy1228682367 commented 2 years ago

Error encountered during processing.Debug info: Anki Version: 2.1.49,AnkiOCR Version: 0.7.1 Platform: Darwin,Python Version: 3.8.6 (v3.8.6:db455296be Sep 23 2020,13:31:39) [Clang 6.0 (clang-600.0.57)Traceback (most recent call last): File "/Users/yzy/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/yzy/Library/Application Support/Anki2/addons21/450181164/ocr.py",line 309,in run_ocr_on_notes notes_query = self.run_ocr -on_query(note_ids=note_ids) File "/Users/yzy/Library/Application Support/Anki2/addons21/450181164/ocr.py",line 277,in run_ocr_on_query batched_txts,batched_txts_dir,batch_mapping =self._gen_batched_txts(notesto process=notes_query.notes, File "/Users/yzy/Library/Application Support/Anki2/addons21/450181164/ocr.py",line 228,in_gen_batched_txts batch_txt_pth.write_text("In" .join(Lstr(i.img_pth) for iin batched_imgsl)) File "pathlib.py",line 1255,in write_text UnicodeEncodeError: "ascii' codec can't encode characters in position 45-46: ordinal not in range(128)

yzy1228682367 commented 2 years ago

and will show this when quitting Anki

Anki 2.1.49 (dc80804a) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2 Platform: Mac 10.16 Flags: frz=True ao=True sv=2 Add-ons, last update check: 2021-12-03 14:56:06

Caught exception: Traceback (most recent call last): File "aqt/progress.py", line 54, in handler File "aqt/utils.py", line 965, in File "aqt/browser/browser.py", line 258, in closeWithCallback File "aqt/browser/browser.py", line 243, in _closeWindow File "aqt/editor.py", line 591, in cleanup File "aqt/editor.py", line 460, in set_note RuntimeError: wrapped C/C++ object of type QWidget has been deleted

elkyr commented 1 year ago

Try changing this : batch_txt_pth.write_text("\n".join([str(i.img_pth) for i in batched_imgs]))

By this : batch_txt_pth.write_text("\n".join([str(i.img_pth) for i in batched_imgs]), encoding='utf-8')

It worked for me!