Pytesseract:FileNotFound
Pytesseract: FileNotFound
我在使用 Pytesser 使用此代码进行测试时遇到了一些问题:
from PIL import Image
import pytesseract
img = Image.open('pic.png')
img.load()
text = pytesseract.image_to_string(img)
print(text)
运行 在 Python 3.4 在 Windows
当 运行 我收到源自 Pytesseract 模块的错误:
Traceback (most recent call last):
File "C:/Users/Gamer/Documents/Python/Bot/test.py", line 6, in <module>
text = pytesseract.image_to_string(img)
File "C:\Python34\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string
config=config)
File "C:\Python34\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "C:\Python34\lib\subprocess.py", line 859, in __init__
restore_signals, start_new_session)
File "C:\Python34\lib\subprocess.py", line 1114, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
我是安装模块的新手,这可能是由于 Tesseract-OCR 或模块的安装或设置不当造成的。
任何帮助将不胜感激,
-尼尔
我在安装 tesseract 时没有遇到任何问题,但我在 UB Mannheim 安装程序中利用了 Tesseract:
https://github.com/UB-Mannheim/tesseract/wiki
您还需要安装 pytesseract:
pip3.6 安装 pytesseract
Python 似乎无法找到图像的位置。我建议使用带有图像路径的变量集来排除任何与 PATH 相关的问题。这是一个例子:
#Path to image folder
src_path = "C:\Users\USERNAME\Documents\OCR\"
#Run OCR on image
text = pytesseract.image_to_string(Image.open(src_path + "pic.png"))
#Print OCR result
print (text)
正如 'st0le' 评论的那样,事实证明需要正确定义 OCR-Tesseract 的路径,而不是图像的路径。
我想我会为其他遇到类似问题的人解决这个问题,因为我现在已经开始工作了。
我在使用 Pytesser 使用此代码进行测试时遇到了一些问题:
from PIL import Image
import pytesseract
img = Image.open('pic.png')
img.load()
text = pytesseract.image_to_string(img)
print(text)
运行 在 Python 3.4 在 Windows
当 运行 我收到源自 Pytesseract 模块的错误:
Traceback (most recent call last):
File "C:/Users/Gamer/Documents/Python/Bot/test.py", line 6, in <module>
text = pytesseract.image_to_string(img)
File "C:\Python34\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string
config=config)
File "C:\Python34\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "C:\Python34\lib\subprocess.py", line 859, in __init__
restore_signals, start_new_session)
File "C:\Python34\lib\subprocess.py", line 1114, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
我是安装模块的新手,这可能是由于 Tesseract-OCR 或模块的安装或设置不当造成的。
任何帮助将不胜感激,
-尼尔
我在安装 tesseract 时没有遇到任何问题,但我在 UB Mannheim 安装程序中利用了 Tesseract:
https://github.com/UB-Mannheim/tesseract/wiki
您还需要安装 pytesseract:
pip3.6 安装 pytesseract
Python 似乎无法找到图像的位置。我建议使用带有图像路径的变量集来排除任何与 PATH 相关的问题。这是一个例子:
#Path to image folder
src_path = "C:\Users\USERNAME\Documents\OCR\"
#Run OCR on image
text = pytesseract.image_to_string(Image.open(src_path + "pic.png"))
#Print OCR result
print (text)
正如 'st0le' 评论的那样,事实证明需要正确定义 OCR-Tesseract 的路径,而不是图像的路径。
我想我会为其他遇到类似问题的人解决这个问题,因为我现在已经开始工作了。