1

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.

nilkash
  • 7,408
  • 32
  • 99
  • 176
  • 2
    Did you verify that you install all dependencies with the Anaconda Python instance? Or do you have multiple Python instances installed and maybe installed your dependencies into a different one? – Thomas Dec 02 '17 at 06:44

2 Answers2

3

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
Thomas
  • 1,026
  • 7
  • 18
  • 2
    Thomas Thank you for quick replay. I tried to install pytesseract in specific env of conda. I tried it with following way : `conda install -n root pytesseract` but it says `PackageNotFoundError: Packages missing in current channels: - pytesseract` . Is there any other way to install in conda env? – nilkash Dec 02 '17 at 07:49
  • 1
    Yeah i tried with pip and it says `Requirement already satisfied: pytesseract in ./anaconda3/lib/python3.6/site-packages` – nilkash Dec 02 '17 at 07:59
  • 1
    but in the same terminal if i try to import it it says `ModuleNotFoundError: No module named 'pytesser'` – nilkash Dec 02 '17 at 08:00
0

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