Tesseract无法在Mac OSX的python上正确安装

时间:2018-12-25 18:56:21

标签: python python-3.x ocr

问题似乎源于以下内容,但不确定是什么原因导致的,因为其所引用的代码是我未编写的,并且假定它是某个模块的一部分?如果有帮助,我正在Mac上使用Anaconda for Python运行MacOSX 10.14。

File "/Users/name/Desktop/Python/OCRTest.py", line 11, in <module>
    import tesseract

File "/anaconda3/lib/python3.6/site-packages/tesseract/__init__.py", line 34
    print 'Creating user config file: {}'.format(_config_file_usr)
                                        ^
SyntaxError: invalid syntax

我尝试过重新安装与Tesseract相关的许多模块,但是我承认我不完全了解我要安装的模块。通常,我只会使用import命令,但是由于这不是标准Python库的一部分,因此我需要安装它。

我在终端中成功使用了以下命令,因此相信我确实具有必需的模块以及此“枕头”程序。

pip install pytesseract
pip install Images
pip install pytesser

(不确定我是否需要最后一个,但是一个站点说我确实这样做了)

这是我正在使用的代码,它只是一个测试程序,可以正常工作。

from PIL import Image
import pytesseract
import tesseract
import pytesser

direct = "/Users/name/Desktop/test.png"
text = pytesseract.image_to_string(Image.open(direct))

这应该从我拥有的图像文件中返回文本“ Rearrange”,其打印后的文本应该不会给它带来任何重大问题。

0 个答案:

没有答案