繁体   English   中英

Tesseract __init__.py引发错误

[英]Tesseract __init__.py throws an error

我正在尝试在python中使用tesseract传递recahptca。 这样做时,将显示以下错误:

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

这是什么问题?

[编辑]

这是我的代码:

import ConfigParser
import os import shutil
# Initialize config file
config_file_def = os.path.join(os.path.dirname(_file),"default_config.ini")
_config_file_usr = os.path.expanduser("~/.tessrc")
if not os.path.isfile(_config_file_usr): 
print 'Creating user config file: {}'.format(_config_file_usr) 
shutil.copyfile(_config_file_def,_config_file_usr) 

您的代码看起来像Python 2.7.x代码。 将您的python版本更改为2.7.x,或者尝试迁移您的代码和依赖项,以便Python 3.x可以解释它。

这里的显着区别是Python 3.x不允许这种伪函数:

print 'Foobar'

它将无法将其识别为有效的语法,这很可能导致您遇到问题。

Python 3会期望您使用print('Foobar')代替。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM