只能 运行 python 来自单独的 tesseract 控制台的代码

Can only run python code from separate tesseract console

我正在使用visual studio编写我的项目,想使用pytesseract进行图像识别,所以我用pip安装了它。然后想我也必须下载 tesseract,所以我下载了它,它可以在带有 'console' 命令行的单独文件夹中找到。问题是,如果我在 visual studio 中尝试 运行ning 我的代码,它说找不到 tesseract。

但如果我通过 tesseract 的命令行 运行 脚本,它工作正常。有没有更方便的方法来执行我的代码?总是从单独的命令行 运行 它似乎有点乏味。

将 tesseract 文件夹添加到系统路径。它应该可以解决问题。

刚刚阅读 documentation:

# If you don't have tesseract executable in your PATH, include the following:
pytesseract.pytesseract.tesseract_cmd = r'<full_path_to_your_tesseract_executable>'