python import : ModuleNotFoundError: No module named 'pytesser'

9.1k views Asked by At

Hi I am new to python and OCR. I am trying to implement OCR. I have installed all the dependencies which are required for OCR. Also important thing is I am using Python provided by Anaconda custom. So when I tried to import pytesser it shows me ModuleNotFoundError: No module named 'pytesser'. I am trying to execute one simple following program :

import sys
print (sys.path)
from PIL import Image
from pytesser import *

image_file = 'imageSample1.jpg'
im = Image.open(image_file)
text = image_to_string(im)
text = image_file_to_string(image_file)
text = image_file_to_string(image_file, graceful_errors=True)
print ("=====output=======\n")
print (text)

And got the following output :

nilkash@nilkash:~/ubuntuBackup/My_Folder/Its_my_work/DS/ML&AI/ImageRecognition$ python SampleImageContentRecognition.py 
['/home/nilkash/ubuntuBackup/My_Folder/Its_my_work/DS/ML&AI/ImageRecognition', '/home/nilkash/anaconda3/lib/python36.zip', '/home/nilkash/anaconda3/lib/python3.6', '/home/nilkash/anaconda3/lib/python3.6/lib-dynload', '/home/nilkash/anaconda3/lib/python3.6/site-packages', '/home/nilkash/anaconda3/lib/python3.6/site-packages/Sphinx-1.5.6-py3.6.egg', '/home/nilkash/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg']
Traceback (most recent call last):
  File "SampleImageContentRecognition.py", line 4, in <module>
    from pytesser import *
ModuleNotFoundError: No module named 'pytesser'

I believe because conda distribution of python it is not able to use it. Is there any way to link it. Or I am doing any thing wrong. Need some help. Thank you.

I drill down to the problem a bit. I have two python version installed one is python2.7 and another one is python3.6. So my all pytesseract configuration are with python2.7. but I am using version 3.6. So I think what I need to do is remove all pytesseract and install against python3.6. Or else move all config to point python3.6. I tried to conda version of pytesseract via conda install -c auto pytesseract but got the following error :

UnsatisfiableError: The following specifications were found to be in conflict:
  - pytesseract -> python 2.7*
  - python 3.6*
Use "conda info <package>" to see the dependencies for each package.

Is there any way to resolve this. Need some help.

2

There are 2 answers

3
Thomas On

you should be able to use PIP in your anaconda prompt Using Pip to install packages to Anaconda Environment

Open the anaconda comand line prompt and install your packages with pip

ie

pip install pytesseract
0
Anne Gao On

It looks they are not under the same path and python can not find it.

Please refer to this link:

How to reset System Variable PATH after tesseract installation