Python 如何使pytesser(Tesseract)工作?
我试图让pytesser在我的mac OS上可以下载,但我没有成功 我安装了Tesseract、PIL和所有依赖项 我解压缩了pythonlib文件夹中的pytesser,并将脚本文件修改为_init__.py 在init文件中,我按照建议修改了tesseract.exe文件的路径 即:Python 如何使pytesser(Tesseract)工作?,python,macos,tesseract,pytesser,Python,Macos,Tesseract,Pytesser,我试图让pytesser在我的mac OS上可以下载,但我没有成功 我安装了Tesseract、PIL和所有依赖项 我解压缩了pythonlib文件夹中的pytesser,并将脚本文件修改为_init__.py 在init文件中,我按照建议修改了tesseract.exe文件的路径 即: tesseract_exe_name = 'my lib path/pytesser/tesseract' # Name of executable to be called at command line
tesseract_exe_name = 'my lib path/pytesser/tesseract' # Name of executable to be called at command line
这就是我得到的错误:
Traceback (most recent call last):
File "<pyshell#50>", line 1, in <module>
print image_to_string(picz)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pytesser/__init__.py", line 31, in image_to_string
call_tesseract(scratch_image_name, scratch_text_name_root)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pytesser/__init__.py", line 21, in call_tesseract
proc = subprocess.Popen(args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1228, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
模块似乎无法运行.exe文件。我试图更改路径,添加扩展名.exe,但总是出现相同的错误。python tesseract包装器的几种解决方案: Python Tesseract: 首先获取自制和brew安装python,然后轻松安装 资料来源: pytesseract:
这就是我在获取python tesseract之前使用的,pip install pytesseract。然后您必须转到/usr/local/lib/python2.7/site-packages,然后转到pytesseract,再转到pytesseract.py。将python脚本中的文件路径更改为tesseract在计算机上的位置。您可能执行了错误的二进制文件。您可以手动尝试tesseract命令吗?i、 e.在外壳中键入tesseract,看看它是否有效。如果可以的话,使用tesseract的结果作为tesseract_exe_name变量的输入。问题是我在Mac上运行。所以我不知道如何从这里运行.exe文件。我猜这就是subprocess.Popen试图做的。。现在我正在尝试另一个,希望能有更多的运气。问题不在tesseract包装器中,而是在tesseract二进制文件中。在mac上不运行.exe,而是运行mac版本的二进制文件。这里的第一步是让tesseract运行,第二步可能是从Python访问它。@Wolph谢谢,这正是我现在要做的:我发现安装和运行tesseract很有用,我以为我已经安装了它,但我不确定我是否成功了。。现在我正在用不同的语言包进行测试,我希望它能起作用一个问题:我能在Mac版本的Tesseract上使用该包装器吗,还是只能在Windows版本上使用该包装器?更新:我尝试以各种方式安装python Tesseract:wget sudo tar zxvf python-Tesseract.macosx-10.8-intel.tar.gz-C/opt/local和svn checkout python Tesseract cd python Tesseract sudo port installpy27 coverage python setup.py clean python setup.py build python setup.py安装,但我总是遇到相同的错误: