pip3安装tesserocr给出错误

时间:2018-05-10 16:52:40

标签: python python-3.x pip python-3.6

我正在尝试在Ubuntu上安装python3.6的tesserocr包。当我运行pip3 install tesserocr时, 我收到这个错误:

Running setup.py bdist_wheel for tesserocr ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-cmhownuf/tesserocr/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 /tmp/tmpg1f69eahpip-wheel- --python-tag cp36:
  Supporting tesseract v4.0.0-beta.1
  Configs from pkg-config: {'include_dirs': ['/usr/include'], 'libraries': ['lept', 'tesseract'], 'cython_compile_time_env': {'TESSERACT_VERSION': 1024}}
  running bdist_wheel
  running build
  running build_ext
  building 'tesserocr' extension
  creating build
  creating build/temp.linux-x86_64-3.6
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-EKG1lX/python3.6-3.6.5=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include -I/usr/include/python3.6m -c tesserocr.cpp -o build/temp.linux-x86_64-3.6/tesserocr.o
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  tesserocr.cpp: In function ‘tesseract::TessResultRenderer* __pyx_f_9tesserocr_13PyTessBaseAPI__get_renderer(__pyx_obj_9tesserocr_PyTessBaseAPI*, __pyx_t_9tesseract_cchar_t*)’:
  tesserocr.cpp:21180:106: error: no matching function for call to ‘tesseract::TessPDFRenderer::TessPDFRenderer(__pyx_t_9tesseract_cchar_t*&, const char*)’
         __pyx_t_3 = new tesseract::TessPDFRenderer(__pyx_v_outputbase, __pyx_v_self->_baseapi.GetDatapath());
                                                                                                            ^
  In file included from tesserocr.cpp:625:0:
  /usr/include/tesseract/renderer.h:190:3: note: candidate: tesseract::TessPDFRenderer::TessPDFRenderer(const char*, const char*, bool)
     TessPDFRenderer(const char* outputbase, const char* datadir, bool textonly);
     ^~~~~~~~~~~~~~~
  /usr/include/tesseract/renderer.h:190:3: note:   candidate expects 3 arguments, 2 provided
  /usr/include/tesseract/renderer.h:186:16: note: candidate: tesseract::TessPDFRenderer::TessPDFRenderer(const tesseract::TessPDFRenderer&)
   class TESS_API TessPDFRenderer : public TessResultRenderer {
                  ^~~~~~~~~~~~~~~
  /usr/include/tesseract/renderer.h:186:16: note:   candidate expects 1 argument, 2 provided
  /usr/include/tesseract/renderer.h:186:16: note: candidate: tesseract::TessPDFRenderer::TessPDFRenderer(tesseract::TessPDFRenderer&&)
  /usr/include/tesseract/renderer.h:186:16: note:   candidate expects 1 argument, 2 provided
  tesserocr.cpp: In function ‘PyObject* PyInit_tesserocr()’:
  tesserocr.cpp:34594:81: error: ‘OEM_CUBE_ONLY’ is not a member of ‘tesseract’
     __pyx_t_10 = __Pyx_PyInt_From_enum__tesseract_3a__3a_OcrEngineMode(tesseract::OEM_CUBE_ONLY); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 84, __pyx_L1_error)
                                                                                   ^~~~~~~~~~~~~
  tesserocr.cpp:34594:81: note: suggested alternative: ‘OEM_LSTM_ONLY’
     __pyx_t_10 = __Pyx_PyInt_From_enum__tesseract_3a__3a_OcrEngineMode(tesseract::OEM_CUBE_ONLY); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 84, __pyx_L1_error)
                                                                                   ^~~~~~~~~~~~~
                                                                                   OEM_LSTM_ONLY
  tesserocr.cpp:34607:81: error: ‘OEM_TESSERACT_CUBE_COMBINED’ is not a member of ‘tesseract’
     __pyx_t_10 = __Pyx_PyInt_From_enum__tesseract_3a__3a_OcrEngineMode(tesseract::OEM_TESSERACT_CUBE_COMBINED); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 85, __pyx_L1_error)
                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  tesserocr.cpp:34607:81: note: suggested alternative: ‘OEM_TESSERACT_LSTM_COMBINED’
     __pyx_t_10 = __Pyx_PyInt_From_enum__tesseract_3a__3a_OcrEngineMode(tesseract::OEM_TESSERACT_CUBE_COMBINED); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 85, __pyx_L1_error)
                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                   OEM_TESSERACT_LSTM_COMBINED
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for tesserocr
  Running setup.py clean for tesserocr
Failed to build tesserocr
Installing collected packages: tesserocr
  Running setup.py install for tesserocr ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-cmhownuf/tesserocr/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-uewp6mk4-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
    Supporting tesseract v4.0.0-beta.1
    Configs from pkg-config: {'include_dirs': ['/usr/include'], 'libraries': ['tesseract', 'lept'], 'cython_compile_time_env': {'TESSERACT_VERSION': 1024}}
    running install
    running build
    running build_ext
    building 'tesserocr' extension
    creating build
    creating build/temp.linux-x86_64-3.6
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-EKG1lX/python3.6-3.6.5=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include -I/usr/include/python3.6m -c tesserocr.cpp -o build/temp.linux-x86_64-3.6/tesserocr.o
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    tesserocr.cpp: In function ‘tesseract::TessResultRenderer* __pyx_f_9tesserocr_13PyTessBaseAPI__get_renderer(__pyx_obj_9tesserocr_PyTessBaseAPI*, __pyx_t_9tesseract_cchar_t*)’:
    tesserocr.cpp:21180:106: error: no matching function for call to ‘tesseract::TessPDFRenderer::TessPDFRenderer(__pyx_t_9tesseract_cchar_t*&, const char*)’
           __pyx_t_3 = new tesseract::TessPDFRenderer(__pyx_v_outputbase, __pyx_v_self->_baseapi.GetDatapath());
                                                                                                              ^
    In file included from tesserocr.cpp:625:0:
    /usr/include/tesseract/renderer.h:190:3: note: candidate: tesseract::TessPDFRenderer::TessPDFRenderer(const char*, const char*, bool)
       TessPDFRenderer(const char* outputbase, const char* datadir, bool textonly);
       ^~~~~~~~~~~~~~~
    /usr/include/tesseract/renderer.h:190:3: note:   candidate expects 3 arguments, 2 provided
    /usr/include/tesseract/renderer.h:186:16: note: candidate: tesseract::TessPDFRenderer::TessPDFRenderer(const tesseract::TessPDFRenderer&)
     class TESS_API TessPDFRenderer : public TessResultRenderer {
                    ^~~~~~~~~~~~~~~
    /usr/include/tesseract/renderer.h:186:16: note:   candidate expects 1 argument, 2 provided
    /usr/include/tesseract/renderer.h:186:16: note: candidate: tesseract::TessPDFRenderer::TessPDFRenderer(tesseract::TessPDFRenderer&&)
    /usr/include/tesseract/renderer.h:186:16: note:   candidate expects 1 argument, 2 provided
    tesserocr.cpp: In function ‘PyObject* PyInit_tesserocr()’:
    tesserocr.cpp:34594:81: error: ‘OEM_CUBE_ONLY’ is not a member of ‘tesseract’
       __pyx_t_10 = __Pyx_PyInt_From_enum__tesseract_3a__3a_OcrEngineMode(tesseract::OEM_CUBE_ONLY); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 84, __pyx_L1_error)
                                                                                     ^~~~~~~~~~~~~
    tesserocr.cpp:34594:81: note: suggested alternative: ‘OEM_LSTM_ONLY’
       __pyx_t_10 = __Pyx_PyInt_From_enum__tesseract_3a__3a_OcrEngineMode(tesseract::OEM_CUBE_ONLY); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 84, __pyx_L1_error)
                                                                                     ^~~~~~~~~~~~~
                                                                                     OEM_LSTM_ONLY
    tesserocr.cpp:34607:81: error: ‘OEM_TESSERACT_CUBE_COMBINED’ is not a member of ‘tesseract’
       __pyx_t_10 = __Pyx_PyInt_From_enum__tesseract_3a__3a_OcrEngineMode(tesseract::OEM_TESSERACT_CUBE_COMBINED); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 85, __pyx_L1_error)
                                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    tesserocr.cpp:34607:81: note: suggested alternative: ‘OEM_TESSERACT_LSTM_COMBINED’
       __pyx_t_10 = __Pyx_PyInt_From_enum__tesseract_3a__3a_OcrEngineMode(tesseract::OEM_TESSERACT_CUBE_COMBINED); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 85, __pyx_L1_error)
                                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                     OEM_TESSERACT_LSTM_COMBINED
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-cmhownuf/tesserocr/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-uewp6mk4-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-cmhownuf/tesserocr/

2 个答案:

答案 0 :(得分:0)

点击tesserocr

的链接

使用conda安装它而不是pip。这将解决您的问题。

conda install -c mcs07 tesserocr

答案 1 :(得分:0)

在Mac中出现相同错误,因为python3已从3.6.3升级到3.7.2,然后安装成功