2017-03-04 155 views
0

我一直試圖安裝Tesseract-ocr庫很長一段時間。閱讀許多與其他軟件包相關的問題並給出解決方案,但都沒有成功。PIP安裝tesseract-ocr:失敗,退出狀態2

我認爲問題是關於我的Microsoft Visual Studio。有下面給出代碼中的錯誤:

錯誤:命令 'C:\ Program Files文件(x86)的\微軟的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\ 

回答

1

考慮使用pytesseract,爲我工作在Python的3.6:PIP安裝pytesseract

如果遇到運行上面的命令直接安裝它的問題,試試這個鏈接: http://www.lfd.uci.edu/~gohlke/pythonlibs/

使用「查找」工具來查找pytesseract和在目錄中的下載,按住shift鍵並點擊右鍵,你會得到一個選項,有打開命令窗口並運行:

PIP安裝「文件名」

你也可以嘗試下載的Tesseract-OCR從上面的鏈接就像我剛纔解釋執行安裝離線。 從來沒有完全弄清楚爲什麼,但一些安裝失敗時工作下載。希望有所幫助。

相關問題