我正在尝试使用以下命令在 Ubuntu 16.04 上为 python 3.5 安装“tesserocr”模块
pip3 install tesserocr --user
或者
sudo pip3 install tesserocr
我已经使用以下方法安装了 Tesseract 3.04 和 Leptonica 1.73:
sudo apt-get install tesseract-ocr libtesseract-dev libleptonica-dev
出于某种原因,当我尝试安装“tesserocr”时,Cython 会生成编译器错误
daksh@daksh-linux:~/tesser/tesseract$ sudo pip3 install tesserocr
[sudo] password for daksh:
The directory '/home/daksh/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/daksh/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting tesserocr
Downloading tesserocr-2.1.2.tar.gz (47kB)
100% |████████████████████████████████| 51kB 1.6MB/s
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/tesserocr.egg-info
writing dependency_links to pip-egg-info/tesserocr.egg-info/dependency_links.txt
writing pip-egg-info/tesserocr.egg-info/PKG-INFO
writing top-level names to pip-egg-info/tesserocr.egg-info/top_level.txt
writing manifest file 'pip-egg-info/tesserocr.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
Supporting tesseract v3.04.01
Configs from pkg-config: {'cython_compile_time_env': {'TESSERACT_VERSION': 197633}, 'libraries': ['tesseract', 'lept'], 'include_dirs': ['/usr/include']}
Error compiling Cython file:
------------------------------------------------------------
...
bool b
bool font_info
TessResultRenderer *temp
TessResultRenderer *renderer = NULL
IF TESSERACT_VERSION >= 0x030401:
^
------------------------------------------------------------
tesserocr.pyx:1862:29: Compile-time name 'TESSERACT_VERSION' not defined
Error compiling Cython file:
------------------------------------------------------------
...
bool b
bool font_info
TessResultRenderer *temp
TessResultRenderer *renderer = NULL
IF TESSERACT_VERSION >= 0x030401:
^
------------------------------------------------------------
tesserocr.pyx:1862:29: Error in compile-time expression: TypeError: unorderable types: NoneType() >= int()
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-jnh9jb37/tesserocr/setup.py", line 166, in <module>
test_suite='tests'
File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 186, in run
self.find_sources()
File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 209, in find_sources
mm.run()
File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 293, in run
self.add_defaults()
File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 322, in add_defaults
sdist.add_defaults(self)
File "/usr/lib/python3/dist-packages/setuptools/command/sdist.py", line 132, in add_defaults
build_ext = self.get_finalized_command('build_ext')
File "/usr/lib/python3.5/distutils/cmd.py", line 299, in get_finalized_command
cmd_obj.ensure_finalized()
File "/usr/lib/python3.5/distutils/cmd.py", line 107, in ensure_finalized
self.finalize_options()
File "/usr/local/lib/python3.5/dist-packages/Cython/Distutils/build_ext.py", line 19, in finalize_options
self.distribution.ext_modules)
File "/usr/local/lib/python3.5/dist-packages/Cython/Build/Dependencies.py", line 925, in cythonize
cythonize_one(*args)
File "/usr/local/lib/python3.5/dist-packages/Cython/Build/Dependencies.py", line 1047, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: tesserocr.pyx
Compiling tesserocr.pyx because it changed.
[1/1] Cythonizing tesserocr.pyx
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-jnh9jb37/tesserocr/
我不明白为什么会这样!:/