question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

windows 10 :pytesseract.pytesseract.TesseractError: (1, 'Error opening data file \\Program Files (x86)\\Tesseract-OCR\\tessdata/chi_sim.traineddata')

See original GitHub issue

I am using pytesseract on windows 10 x64, and the python is 3.5.2 x64, Tesseract is 4.0 ,the code is as follow:

# -*- coding: utf-8 -*-

try:
    import Image
except ImportError:
    from PIL import Image
import pytesseract


print(pytesseract.image_to_string(Image.open('d:/testimages/name.gif'), lang='chi_sim'))

error:

Traceback (most recent call last):
  File "D:/test.py", line 10, in <module>
    print(pytesseract.image_to_string(Image.open('d:/testimages/name.gif'), lang='chi_sim'))
  File "C:\Users\dell\AppData\Local\Programs\Python\Python35\lib\site-packages\pytesseract\pytesseract.py", line 165, in image_to_string
    raise TesseractError(status, errors)
pytesseract.pytesseract.TesseractError: (1, 'Error opening data file \\Program Files (x86)\\Tesseract-OCR\\tessdata/chi_sim.traineddata')

C:\Program Files (x86)\Tesseract-OCR\tessdata,like this:

enter image description here

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:25

github_iconTop GitHub Comments

50reactions
int3lcommented, May 15, 2017

@zwl1619, @coollorenzo, Finally managed to reproduce this error.

Please try to use the config option with pytesseract like this:


tessdata_dir_config = '--tessdata-dir "<replace_with_your_tessdata_dir_path>"'
# Example config: '--tessdata-dir "C:\\Program Files (x86)\\Tesseract-OCR\\tessdata"'
# It's important to include double quotes around the dir path.

pytesseract.image_to_string(image, lang='chi_sim', config=tessdata_dir_config)

If this workaround works for you, I will include the snippet to the README file.

16reactions
jtbrcommented, Mar 15, 2017

This occurs under windows (at least in tesseract version 3.05) when the current directory is on a different drive from where tesseract is installed.

Something in tesseract is expecting data files to be in \Program Files… (rather than C:\Program Files, say). So if you’re not on the same drive letter as tesseract, it will fail. It would be great if we could work around it by temporarily changing drives (under windows only) to the tesseract installation drive before executing tesseract, and changing back after.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pytesseract: Error opening data file \\Program Files (x86) ...
Finally, I solved the problem by replacing. pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe'.
Read more >
Issue 568 in tesseract-ocr: error opening data file
in cmd I run tesseract cn test the cmd display error opening data file eng.traineddata. I think it's the file separator issue, how...
Read more >
pytesseract
Add the following config, if you have tessdata error like: “Error opening data file…” # Example config: r'--tessdata-dir "C:\Program Files (x86)\Tesseract-OCR\ ...
Read more >
How to upload new .traineddata file in pytesseract ...
TesseractError : (1, 'Tesseract Open Source OCR Engine v3.04.01 with Leptonica Error opening data file /usr/share/tesseract-ocr/tessdata/ocr.
Read more >
Problems with Tesseract OCR : r/learnmachinelearning
Error opening data file \\Program Files\\Tesseract-OCR\\tessdata/eng.traineddata Please make sure the TESSDATA_PREFIX environment variable ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found