Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在终端中找不到Tesseract_Python_Tesseract_Python Tesseract - Fatal编程技术网

Python 在终端中找不到Tesseract

Python 在终端中找不到Tesseract,python,tesseract,python-tesseract,Python,Tesseract,Python Tesseract,我与tesseract有问题(我与Pycharm合作)。 当我运行脚本时,一切都正常。但是,当我定义一个方法并在终端中运行它时,它会引发一个错误: TesseractNotFoundError: C:\Users\nom_utilisateur\AppData\Local\Tesseract-OCR\tesseract is not installed or it's not in your path 问题是,为什么它显示了一条我在脚本开头没有定义为tesseract路径的路径?这是我剧本的开

我与tesseract有问题(我与Pycharm合作)。 当我运行脚本时,一切都正常。但是,当我定义一个方法并在终端中运行它时,它会引发一个错误:

TesseractNotFoundError: C:\Users\nom_utilisateur\AppData\Local\Tesseract-OCR\tesseract is not installed or it's not in your path
问题是,为什么它显示了一条我在脚本开头没有定义为tesseract路径的路径?这是我剧本的开头:

from PIL import Image
import re
import argparse
import cv2
import pytesseract
import numpy as np
from pytesseract import Output
import sys
pytesseract.pytesseract.tesseract_cmd = r'C:/Program Files/Tesseract-OCR/tesseract.exe'
我的方法:

if __name__ == "__main__":
     img_path = sys.argv[1]
     corrections_file = sys.argv[2]
     output_img_file = sys.argv[3]
     output_text_file = sys.argv[4]
     demo(img_path, corrections_file, output_img_file, output_text_file)
还有Pycharm终端的结果截屏

根据,Tesseract的默认安装路径是
C:\Users\USER\AppData\Local\Tesseract OCR
pytesseract
需要实际的tesseract可执行文件,因此需要将其设置为
pytesseract.pytesseract.tesseract\u cmd=r'\tesseract.exe'