Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stripped "\" from Windows Tessdata Path #356

Closed
tallsmallone opened this issue May 28, 2021 · 1 comment · Fixed by #502
Closed

Stripped "\" from Windows Tessdata Path #356

tallsmallone opened this issue May 28, 2021 · 1 comment · Fixed by #502
Labels

Comments

@tallsmallone
Copy link

When trying to run pytesseract from a windows 10 environment, I found that the config was stripping the \ in my tessdata path.

I found that the solution to fix this was in pytesseract.py: line 251:

if config:
cmd_args += shlex.split(config, posix=False)

To confirm it was the issue, here was the config before this section of code:
--tessdata-dir E:\Projects\fhm-test-automation\tessdata --oem 3 --psm 3

And after the shlex.split(), the cmd_args was now:
['tesseract', 'C:\\Users\\nickr\\AppData\\Local\\Temp\\tess_ai78chdv.PNG', 'C:\\Users\\nickr\\AppData\\Local\\Temp\\tess_ai78chdv', '-l', 'eng', '--tessdata-dir', 'E:Projectsfhm-test-automationtessdata', '--oem', '3', '--psm', '3']

Please note that I truncated off the extra, unneeded information.

As you can see, the --tessdata-dir was altered, thus giving the dreaded TESSDATA_PREFIX error.

I would make a PR myself, but I do not know enough about the system to know the consequences on my actions.

@bozhodimitrov
Copy link
Collaborator

bozhodimitrov commented May 28, 2021

Hi @tallsmallone
Thank you for reporting the issue.
This seems like a platform specific bug.
For reference, this is how numpy does the parsing: https://github.com/numpy/numpy/blob/main/numpy/distutils/_shell_utils.py
Maybe we can use some built-in method for solving this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants