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

Traineddata path issue on Windows 10. #14

Open
gety9 opened this issue Mar 15, 2022 · 8 comments
Open

Traineddata path issue on Windows 10. #14

gety9 opened this issue Mar 15, 2022 · 8 comments

Comments

@gety9
Copy link

gety9 commented Mar 15, 2022

When i run

python -m table_ocr.demo https://raw.githubusercontent.com/eihli/image-table-ocr/master/resources/test_data/simple.png

i get

pytesseract.pytesseract.TesseractError: (1, 'Error opening data file C:UsersGetyAppDataLocalProgramsPythonPython38libsite-packagestable_ocrtessdata/table-ocr.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language \'table-ocr\' Tesseract couldn\'t load any languages! Could not initialize tesseract.')

(note file path does not have '/')

File does exist

I tried setting env variable TESSDATA_PREFIX - same error.

as well as specifying path in cli python -m table_ocr.demo https://raw.githubusercontent.com/eihli/image-table-ocr/master/resources/test_data/simple.png --tessdata-dir C:\Users\Btycoon\AppData\Local\Programs\Python\Python38\Lib\site-packages\table_ocr\tessdata

I am on Windows 10.

@eihli
Copy link
Owner

eihli commented Mar 20, 2022

Sorry to say that I have very little knowledge of Windows 10. I'll leave this comment open for a while in case anyone else has a suggestion.

@MikuAuahDark
Copy link

MikuAuahDark commented Apr 12, 2022

I'd write my workaround.

tess_args = ["--psm", "7", "-l", "table-ocr", "--tessdata-dir", tessdata_dir]

Replace all backslash to forward slashes. tessdata_dir.replace("\\", "/").

After making the necessary changes, the program works. Windows 10, Python 3.10.4.

@MikuAuahDark
Copy link

Also I found out that the built-in Tesseract data that my installation has is more superior compared to the shipped one, so I removed the related line entirely.

@GeniusBroccoli
Copy link

GeniusBroccoli commented May 8, 2022

Replace all backslash to forward slashes. tessdata_dir.replace("\", "/").

Thank you, I was trying to find a problem all day

@eihli
Copy link
Owner

eihli commented Dec 15, 2022

If anyone wants to submit a patch to make this more portable across Linux/Windows, please do!

@ajay27bhat
Copy link

When i run

python -m table_ocr.demo https://raw.githubusercontent.com/eihli/image-table-ocr/master/resources/test_data/simple.png

i get

pytesseract.pytesseract.TesseractError: (1, 'Error opening data file C:UsersGetyAppDataLocalProgramsPythonPython38libsite-packagestable_ocrtessdata/table-ocr.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language \'table-ocr\' Tesseract couldn\'t load any languages! Could not initialize tesseract.')

(note file path does not have '/')

File does exist

I tried setting env variable TESSDATA_PREFIX - same error.

as well as specifying path in cli python -m table_ocr.demo https://raw.githubusercontent.com/eihli/image-table-ocr/master/resources/test_data/simple.png --tessdata-dir C:\Users\Btycoon\AppData\Local\Programs\Python\Python38\Lib\site-packages\table_ocr\tessdata

I am on Windows 10.

I am also getting same error. Did you solve this problem?

@rucxiaowen
Copy link

rucxiaowen commented May 23, 2023 via email

@ajay27bhat
Copy link

I'd write my workaround.

tess_args = ["--psm", "7", "-l", "table-ocr", "--tessdata-dir", tessdata_dir]

Replace all backslash to forward slashes. tessdata_dir.replace("\\", "/").

After making the necessary changes, the program works. Windows 10, Python 3.10.4.

How do I run this project after I make changes? I am new to this. So can you please guide on how to run this project? Thanks

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

No branches or pull requests

6 participants