Unable to install tesseract-ocr through PIP command

Unable to install tesseract-ocr through PIP commend and getting below error. can you let me know how do fix this?
Currently I am using latest python 3.12.0 and PIP (23.2.1) versions

Collecting tesseract-ocr
Using cached https://dockercentral.it.att.com:8094/nexus/repository/pypi-group/packages/tesseract-ocr/0.0.1/tesseract-ocr-0.0.1.tar.gz (33 kB)
Installing build dependencies … done
Getting requirements to build wheel … done
Preparing metadata (pyproject.toml) … done
Collecting cython (from tesseract-ocr)
Using cached https://dockercentral.it.att.com:8094/nexus/repository/pypi-group/packages/cython/3.0.7/Cython-3.0.7-cp312-cp312-win_amd64.whl (2.8 MB)
Building wheels for collected packages: tesseract-ocr
Building wheel for tesseract-ocr (pyproject.toml) … error
error: subprocess-exited-with-error

× Building wheel for tesseract-ocr (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
C:\Users\gk146\AppData\Local\Temp\pip-build-env-n0_8_wgx\overlay\Lib\site-packages\setuptools\dist.py:472: SetuptoolsDeprecationWarning: Invalid dash-separated options
!!

          ********************************************************************************
          Usage of dash-separated 'description-file' will not be supported in future
          versions. Please use the underscore name 'description_file' instead.

          By 2024-Sep-26, you need to update your project and remove deprecated calls
          or your builds will no longer be supported.

          See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
          ********************************************************************************

  !!
    opt = self.warn_dash_deprecation(opt, section)
  running bdist_wheel
  running build
  running build_py
  file tesseract_ocr.py (for module tesseract_ocr) not found
  file tesseract_ocr.py (for module tesseract_ocr) not found
  running build_ext
  building 'tesseract_ocr' extension
  creating build
  creating build\temp.win-amd64-cpython-312
  creating build\temp.win-amd64-cpython-312\Release
  "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\gk146\AppData\Local\Programs\Python\Python312\include -IC:\Users\gk146\AppData\Local\Programs\Python\Python312\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" /EHsc /Tptesseract_ocr.cpp /Fobuild\temp.win-amd64-cpython-312\Release\tesseract_ocr.obj
  tesseract_ocr.cpp
  tesseract_ocr.cpp(264): fatal error C1083: Cannot open include file: 'leptonica/allheaders.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for tesseract-ocr
Failed to build tesseract-ocr
ERROR: Could not build wheels for tesseract-ocr, which is required to install pyproject.toml-based projects

(The version seems to be too old)

If you need tesseract-ocr for Python, then it is better to use pytesseract GitHub - madmaze/pytesseract: A Python wrapper for Google Tesseract.

But you need to take care with the version of Python. Usually, libraries take some time to be updated to latest versions. This could be the case with Python 3.12.

1 Like