5

I am using Anaconda Navigator 1.7.0 on windows 10, I have created a virtual environment named "venv" and installed Python version 3.5.2 in that along with selenium, fuzzywuzzy and other modules.

Everything works just fine except pytesseract.

My python script:

import pytesseract

from PIL import Image

im =Image.open("C:\\Users\\stan\\Desktop\\sample.jpg")
text = pytesseract.image_to_string(im, lang ='eng')
print(text)

I get the below error:

Traceback (most recent call last):
  File "C:\Users\stan\MyPythonScripts\tess11.py", line 1, in <module>
    import pytesseract
ModuleNotFoundError: No module named 'pytesseract'

I used pip install to install all modules.

Steps taken by me to solve this till now:

  1. I installed pytesseract in the virtual env using pip install pytesseract from inside that virtual environment (venv),
  2. I looked into the "site-packages" folder (..\Local\Continuum\anaconda3\envs\venv\Lib\site-packages) and I do see that "pytesseract" folder does exist there along with "pytesseract-0.2.0.dist-info". Note that this is also the folder where I can see "selenium" and other modules which run perfectly fine.
  3. I installed Pillow just to make sure.

  4. I researched online for the same error and found solutions stating that I should pip install pytesseract and also check if pytesseract exists in my "site-packages" of the virtual env which I am trying to run in, both of which steps I have already taken.

  5. I have also installed tesseract-OCR version 3.05.01, which is, by default, located in "C:\Program Files (x86)"

  6. If I try to run pip install pytesseract again just below the "ModuleNotFoundError", I get the below message:

    Requirement already satisfied: pytesseract in c:\users\stan\appdata\local\continuum\anaconda3\envs\venv\lib\site-packages (0.2.0) Requirement already satisfied: Pillow in c:\users\stan\appdata\local\continuum\anaconda3\envs\venv\lib\site-packages (from pytesseract) (5.1.0)

  7. I have also tried uninstalling pytesseract and manually deleting any file name containing pytesseract from the system and then installed pytesseract again.

Can any one kindly suggest what I might be missing or point me in the direction where I can research on this topic?

Is there any alternate way of installing pytesseract apart from pip install, which might help in this scenario?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Stan
  • 227
  • 5
  • 13
  • Update: I tried the same on my other computer, updated the version of Anaconda, and currently I am getting the exact same error in the other computer as well. In the other computer I also added the link of "pytesseract"(..\Local\Continuum\anaconda3\envs\venv\Lib\site-packages) to the "system environment variables", but did not help. – Stan Apr 24 '18 at 19:03
  • 1
    Generally, when you install the module with pip it install to the location of the interpreter, which is exported to the environment. check if you have python installed on your machine. now, if you want to install the package on anaconda try with command:- conda install This will install the package in anaconda. It seems to me issue appeared because of two python installation in different path. – jits_on_moon Jul 16 '18 at 12:07
  • also try on dos prompt. type python and import module on python shell, let me know what you get. There is no issue with package, i have installed on my machine. it works as exxpected. – jits_on_moon Jul 16 '18 at 12:09
  • Which IDE are you using? I once had the same problem with vscode. Activated my environment containing the package but forgot defining the environment corresponding to the workspace in vscode directly. – Lena May 12 '19 at 16:59
  • Try to import via command prompt or Anaconda prompt. That might narrow down whether it is an IDE problem or not – Deepan Raj Aug 14 '19 at 14:12
  • I have the same problem. – Tamas Jun 24 '22 at 10:47

0 Answers0