It's not possible to use a character whitelist with a spacebar on windows

Author: art0007iCreated Jun 23, 2025Updated Aug 7, 2025

I hope I am not overlooking something obvious but from my experiments it seems not possible to use a character whitelist which has a spacebar in it on windows

I tried: pytesseract.image_to_string(img, config=conf) where conf is "--psm 6 -c tessedit_char_whitelist=' 0123456789'" '--psm 6 -c tessedit_char_whitelist=" 0123456789"' "--psm 6 -c tessedit_char_whitelist=\' 0123456789\'" '--psm 6 -c tessedit_char_whitelist=\" 0123456789\"'

none of those worked, it seems that the underlying code is running shlex.split with posix=False on windows. this makes it ALWAYS split on a spacebar ignoring quotes, I edited pytesseract's source code to set posix=True even on windows and it fixed my issue.