madmaze / pytesseract

A Python wrapper for Google Tesseract
Apache License 2.0
5.77k stars 714 forks source link

ModuleNotFoundError: No module named 'pytesseract' #495

Closed lucasroblin closed 1 year ago

lucasroblin commented 1 year ago

I've installed everything, I can run Tesseract from the terminal, the "tox" command sent me a " py: OK (0.05 seconds) congratulations :) (0.16 seconds)" (after a root thing saying it's empty but in the end it works), but whenever I'm trying to run try: from PIL import Image except ImportError: import Image import pytesseract print(pytesseract.image_to_string(Image.open('/users/lucas/desktop/image.png'))) i have the error message "ModuleNotFoundError: No module named 'pytesseract'". Any solutions please ?

MacOS version : 13.4.1 Python version : 3.9.0

stefan6419846 commented 1 year ago

tox running this fast seems to indicate that indeed no tests have been executed (for comparison: CI needs about 30 seconds). What is the full tox output? (Additionally, tox will usually use a dedicated virtual environment for its tests.)

Are you sure you are running your tests with the same interpreter as the one you have "installed everything" with? If you use python script.py for your tests, does python -m pip show pytesseract show any output?

lucasroblin commented 1 year ago

Here is the tox full output :

ROOT: No tox.ini or setup.cfg or pyproject.toml found, assuming empty tox.ini at /Users/lucas py: OK (0.06 seconds) congratulations :) (0.18 seconds)

For the tests, I'm running tox test and general Tesseract text via the terminal, whereas I run the script from a folder on my desktop on Vscode.

This is what I have after running python3 desktop/TESSERACT/test_pytesseract.py

Traceback (most recent call last): File "/Users/lucas/desktop/TESSERACT/test_pytesseract.py", line 7, in import pytesseract ModuleNotFoundError: No module named 'pytesseract

And for the last part : python3 -m pip show pytesseract WARNING: Package(s) not found: pytesseract

EDIT : with the result of these test I tried to do a pip install pytesseract but as a result I had

Requirement already satisfied: pytesseract in /usr/local/lib/python3.11/site-packages (0.3.10) Requirement already satisfied: packaging>=21.3 in /usr/local/lib/python3.11/site-packages (from pytesseract) (23.1) Requirement already satisfied: Pillow>=8.0.0 in /usr/local/lib/python3.11/site-packages (from pytesseract) (10.0.0)

stefan6419846 commented 1 year ago

In this case, tox is not running as expected. You will have to download the pytesseract source and unpack it, then run tox from within the unpacked directory. You should not get any warning about missing files when running tox. Nevertheless, please note that tox is only required for the self-tests and not for regular usage.

The further outputs indicate that you indeed did not correctly install pytesseract for your interpreter.

EDIT : with the result of these test I tried to do a pip install pytesseract but as a result I had

You appear to have two different Python versions, with the default one being Python 3.11. python3 points to Python 3.9(?) nevertheless (at least this is what you mention in your initial report). To get pytesseract for python3, you might need python3 -m pip install --upgrade pytesseract.

lucasroblin commented 1 year ago

I tried what you said and the usual, it tells me that I already have it. I'm gonna try to install pytesseract via vscode's terminal

lucasroblin commented 1 year ago

Well idk if it's the python3 -m pip install --upgrade pytesseract or the installation in vscode's terminal instead of the computer's terminal but now it's okay

stefan6419846 commented 1 year ago

As already mentioned, this appears to be a general package installation problem on your side or some interpreter mix-up - and nothing which would be pytesseract specific. It seems like Visual Studio Code might use its own or another interpreter (for example with its own virtual environment).