解决mac pip3 install tesserocr 超时 或者报错

tesserocr 是处理OCR问题的工具
在安装过程中,可能遇到下面的问题:

Collecting tesserocr
  Using cached tesserocr-2.5.1.tar.gz (54 kB)
Building wheels for collected packages: tesserocr
  Building wheel for tesserocr (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/*****/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/r3/1zvnrkd94q58nvvrd7p_ym840000gn/T/pip-install-h7n007fs/tesserocr/setup.py'"'"'; __file__='"'"'/private/var/folders/r3/1zvnrkd94q58nvvrd7p_ym840000gn/T/pip-install-h7n007fs/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 /private/var/folders/r3/1zvnrkd94q58nvvrd7p_ym840000gn/T/pip-wheel-c0wgmx50
       cwd: /private/var/folders/r3/1zvnrkd94q58nvvrd7p_ym840000gn/T/pip-install-h7n007fs/tesserocr/
  Complete output (15 lines):
  Supporting tesseract v4.1.1
  Configs from pkg-config: {'library_dirs': ['/usr/local/Cellar/tesseract/4.1.1/lib', '/usr/local/Cellar/leptonica/1.79.0/lib'], 'include_dirs': ['/usr/local/Cellar/tesseract/4.1.1/include', '/usr/local/Cellar/leptonica/1.79.0/include', '/usr/local/Cellar/leptonica/1.79.0/include'], 'libraries': ['tesseract', 'curl', 'lept'], 'cython_compile_time_env': {'TESSERACT_VERSION': 67174656}}
  running bdist_wheel
  running build
  running build_ext
  building 'tesserocr' extension
  creating build
  creating build/temp.macosx-10.7-x86_64-3.6
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/*****/anaconda3/include -arch x86_64 -I/Users/*****/anaconda3/include -arch x86_64 -I/usr/local/Cellar/tesseract/4.1.1/include -I/usr/local/Cellar/leptonica/1.79.0/include -I/usr/local/Cellar/leptonica/1.79.0/include -I/Users/*****/anaconda3/include/python3.6m -c tesserocr.cpp -o build/temp.macosx-10.7-x86_64-3.6/tesserocr.o -std=c++11 -DUSE_STD_NAMESPACE
  In file included from tesserocr.cpp:591:
  /usr/local/Cellar/tesseract/4.1.1/include/tesseract/genericvector.h:25:10: fatal error: 'cstdint' file not found
  #include <cstdint>      // for uint32_t
           ^~~~~~~~~
  1 error generated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: 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
    ERROR: Command errored out with exit status 1:
     command: /Users/*****/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/r3/1zvnrkd94q58nvvrd7p_ym840000gn/T/pip-install-h7n007fs/tesserocr/setup.py'"'"'; __file__='"'"'/private/var/folders/r3/1zvnrkd94q58nvvrd7p_ym840000gn/T/pip-install-h7n007fs/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 /private/var/folders/r3/1zvnrkd94q58nvvrd7p_ym840000gn/T/pip-record-4i75zq_r/install-record.txt --single-version-externally-managed --compile --install-headers /Users/*****/anaconda3/include/python3.6m/tesserocr
         cwd: /private/var/folders/r3/1zvnrkd94q58nvvrd7p_ym840000gn/T/pip-install-h7n007fs/tesserocr/
    Complete output (15 lines):
    Supporting tesseract v4.1.1
    Configs from pkg-config: {'library_dirs': ['/usr/local/Cellar/tesseract/4.1.1/lib', '/usr/local/Cellar/leptonica/1.79.0/lib'], 'include_dirs': ['/usr/local/Cellar/tesseract/4.1.1/include', '/usr/local/Cellar/leptonica/1.79.0/include', '/usr/local/Cellar/leptonica/1.79.0/include'], 'libraries': ['tesseract', 'curl', 'lept'], 'cython_compile_time_env': {'TESSERACT_VERSION': 67174656}}
    running install
    running build
    running build_ext
    building 'tesserocr' extension
    creating build
    creating build/temp.macosx-10.7-x86_64-3.6
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/*****/anaconda3/include -arch x86_64 -I/Users/*****/anaconda3/include -arch x86_64 -I/usr/local/Cellar/tesseract/4.1.1/include -I/usr/local/Cellar/leptonica/1.79.0/include -I/usr/local/Cellar/leptonica/1.79.0/include -I/Users/*****/anaconda3/include/python3.6m -c tesserocr.cpp -o build/temp.macosx-10.7-x86_64-3.6/tesserocr.o -std=c++11 -DUSE_STD_NAMESPACE
    In file included from tesserocr.cpp:591:
    /usr/local/Cellar/tesseract/4.1.1/include/tesseract/genericvector.h:25:10: fatal error: 'cstdint' file not found
    #include <cstdint>      // for uint32_t
             ^~~~~~~~~
    1 error generated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/*****/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/r3/1zvnrkd94q58nvvrd7p_ym840000gn/T/pip-install-h7n007fs/tesserocr/setup.py'"'"'; __file__='"'"'/private/var/folders/r3/1zvnrkd94q58nvvrd7p_ym840000gn/T/pip-install-h7n007fs/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 /private/var/folders/r3/1zvnrkd94q58nvvrd7p_ym840000gn/T/pip-record-4i75zq_r/install-record.txt --single-version-externally-managed --compile --install-headers /Users/*****/anaconda3/include/python3.6m/tesserocr Check the logs for full command output.









解决方案:输入如下命令:

CC=clang XCC=clang++ CPPFLAGS="-stdlib=libc++ -DUSE_STD_NAMESPACE -mmacosx-version-min=10.8" pip3 install -i https://pypi.doubanio.com/simple/ tesserocr pillow

发布了14 篇原创文章 · 获赞 1 · 访问量 584

猜你喜欢

转载自blog.csdn.net/Serendi_patty/article/details/105358582