我正在尝试在 Google App Engine 上部署一个也具有 OCR 功能的应用程序。我使用 homebrew 下载了 tesseract,并使用pytesseractPython 进行包装。OCR 功能在我的本地系统上有效,但当我将应用程序上传到 Google App Engine 时却不起作用。
我tesseract从 usr/local/cellar/tesseract 复制文件夹并粘贴到我的应用程序的工作目录中。我将超正方文件和pytesseract文件上传到应用程序引擎。我已经指定了 tesseract 的路径,os.getcwd()以便pytesseract可以找到它。然而,这是行不通的。App Engine 找不到要执行的文件,因为它们不在同一目录 ( os.getcwd()) 中。
代码来自 pytesseract.py
cmda = os.getcwd()
# CHANGE THIS IF TESSERACT IS NOT IN YOUR PATH, OR IS NAMED DIFFERENTLY
def find_all(name, path):
result = []
for root, dirs, files in os.walk(path):
if name in files:
result.append(os.path.join(root, name))
return result
founds = find_all("tesseract",cmda)
tesseract_cmd …Run Code Online (Sandbox Code Playgroud)