pytesseract 无法正常工作

pytesseract 无法正常工作
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> from PIL import Image
>>> import pytesseract
>>> i=Image.open("C:\Users\dharaneeshvrd\Desktop\img.jpg

扫描字符串文字时出现语法错误:EOL

>>> i=Image.open("C:\Users\dharaneeshvrd\Desktop\img.jpg")
>>> print pytesseract.image_to_string(i)

回溯(最近一次调用最后一次):文件“”,第 1 行,在 print pytesseract.image_to_string(i)文件“C:\Python27\lib\site-packages\pytesseract\pytesseract.py”,第 161 行,在 image_to_string config=config)文件“C:\Python27\lib\site-packages\pytesseract\pytesseract.py”,第 94 行,在 run_tesseract stderr=subprocess.PIPE)文件“C:\Python27\lib\subprocess.py”,第 390 行,在在里面 errread,errwrite)文件“C:\Python27\lib\subprocess.py”,第 640 行,在 _execute_child startupinfo 中)WindowsError:[错误 2] 系统找不到指定的文件

>

我做错了什么?我已经使用 pip 安装了 pytesseract

pip install pytesseract

和枕头

pip install pillow

答案1

正如错误中所述:

该系统找不到指定的文件

文件名 -C:\用户\dharaneeshvrd\桌面\img.jpg- 不正确(或不存在)。

假设你在Ubuntu上运行,文件名格式应该有所不同。

我建议,首先,识别驱动器中的文件,其次,发出:

ls -lsa /full/path/name

确保路径写得正确,然后在 Python 脚本中使用它

相关内容