1

我一直在尝试安装 Tesseract-ocr 库。阅读与其他软件包相关的许多类似问题并给出解决方案,但没有一个有效。

我认为问题出在我的 Microsoft Visual Studio 上。给出以下代码时出现错误:

错误:命令 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\x86_amd64\cl.exe' 失败,退出状态为 2

我卸载、重新安装、更新并尝试了很多东西,但仍然无法正常工作:(

现在已经谢谢了!

C:\Users\af>pip install tesseract-ocr
Collecting tesseract-ocr
  Using cached tesseract-ocr-0.0.1.tar.gz
Requirement already satisfied: cython in c:\python34\lib\site-packages (from tesseract-ocr)
Building wheels for collected packages: tesseract-ocr
  Running setup.py bdist_wheel for tesseract-ocr ... error
  Complete output from command c:\python34\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\af\\AppData\\Local\\Temp\\pip-build-ggf9qvw1\\tesseract-ocr\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\af\AppData\Local\Temp\tmpdnkpad7cpip-wheel- --python-tag cp34:
  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-3.4
  creating build\temp.win-amd64-3.4\Release
  c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\x86_amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\python34\include -Ic:\python34\include /Tptesseract_ocr.cpp /Fobuild\temp.win-amd64-3.4\Release\tesseract_ocr.obj
  tesseract_ocr.cpp
  tesseract_ocr.cpp(463) : fatal error C1083: Cannot open include file: 'leptonica/allheaders.h': No such file or directory
  error: command 'c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\Bin\\x86_amd64\\cl.exe' failed with exit status 2

  ----------------------------------------
  Failed building wheel for tesseract-ocr
  Running setup.py clean for tesseract-ocr
Failed to build tesseract-ocr
Installing collected packages: tesseract-ocr
  Running setup.py install for tesseract-ocr ... error
    Complete output from command c:\python34\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\af\\AppData\\Local\\Temp\\pip-build-ggf9qvw1\\tesseract-ocr\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\af\AppData\Local\Temp\pip-tcjuee8m-record\install-record.txt --single-version-externally-managed --compile:
    running install
    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-3.4
    creating build\temp.win-amd64-3.4\Release
    c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\x86_amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\python34\include -Ic:\python34\include /Tptesseract_ocr.cpp /Fobuild\temp.win-amd64-3.4\Release\tesseract_ocr.obj
    tesseract_ocr.cpp
    tesseract_ocr.cpp(463) : fatal error C1083: Cannot open include file: 'leptonica/allheaders.h': No such file or directory
    error: command 'c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\Bin\\x86_amd64\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "c:\python34\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\af\\AppData\\Local\\Temp\\pip-build-ggf9qvw1\\tesseract-ocr\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\af\AppData\Local\Temp\pip-tcjuee8m-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\af\AppData\Local\Temp\pip-build-ggf9qvw1\tesseract-ocr\
4

2 回答 2

1

考虑使用 pytesseract,在 python 3.6 上为我工作:pip install pytesseract

如果通过运行上述命令直接安装它时遇到问题,请尝试以下链接: http ://www.lfd.uci.edu/~gohlke/pythonlibs/

使用“查找”工具找到 pytesseract 并在下载它的目录中,按住 shift 并右键单击,您将获得一个选项以在此处打开命令窗口并运行:

点安装“文件名”

您也可以尝试从上面的链接下载 tesseract-ocr 并像我刚才解释的那样离线执行安装。从来没有完全弄清楚为什么,但一些失败的安装在下载时工作。希望有帮助。

于 2017-03-04T18:14:39.557 回答
0

此问题的修复在tesseract-ocr的编译页面上

sudo apt-get install libleptonica-dev

我可以告诉你,这解决了 Raspberry Pi(Jessie 和 Stretch)和 Debian(8 和 9)上的问题

于 2019-01-25T00:39:22.540 回答