K
K
kaleon2020-07-12 21:10:34
Python
kaleon, 2020-07-12 21:10:34

How to enable cyrillic in pytesseract?

When I try to include an example from github, only with the ru language, it gives an error

File C:\Users\kaleon\AppData\Local\Programs\Python\Python38-32\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-7: character maps to undefined


The code itself
try:
    from PIL import Image
except ImportError:
    import Image
import pytesseract

print(pytesseract.image_to_string(Image.open('image.jpg') lang='rus'))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
half_man, 2020-07-16
@half_man

Try adding a comma before lang='rus'

print(pytesseract.image_to_string(Image.open('image.jpg'), lang='rus'))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question