Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/315.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.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 pytesser子进程。Popen失败_Python_Ocr_Pytesser - Fatal编程技术网

Python pytesser子进程。Popen失败

Python pytesser子进程。Popen失败,python,ocr,pytesser,Python,Ocr,Pytesser,从昨天起,我就开始尝试使用OCR打印机。 我自己解决了几个问题,但我不知道如何解决这个问题。 有一个错误: H:\Python27>python.exe lol.py Traceback (most recent call last): File "lol.py", line 30, in <module> print image_to_string(image) File "H:\Python27\lib\pytesser\__init__.py", line 30, in

从昨天起,我就开始尝试使用OCR打印机。 我自己解决了几个问题,但我不知道如何解决这个问题。 有一个错误:

H:\Python27>python.exe lol.py
Traceback (most recent call last):
File "lol.py", line 30, in <module>
print image_to_string(image)
File "H:\Python27\lib\pytesser\__init__.py", line 30, in image_to_string
call_tesseract(scratch_image_name, scratch_text_name_root)
File "H:\Python27\lib\pytesser\__init__.py", line 20, in call_tesseract
proc = subprocess.Popen(args)
File "H:\Python27\lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "H:\Python27\lib\subprocess.py", line 958, in _execute_child
 startupinfo)
WindowsError: [Error 2] Le fichier spÚcifiÚ est introuvable
我真不明白他为什么不能打开文件。在myinit.py中,还有另外两件事。我可以更改我试图创建的图像文件和txt文件,并给他路径,但没有成功,但我认为是他自己创建的

scratch_image_name = "outfile.bmp" # This file must be .bmp or other Tesseract-compatible format
scratch_text_name_root = "infile" # Leave out the .txt extension
这是发送到Popen的3个文件,所以我想错误就在那里

我希望我足够清楚,让你们理解我的问题

编辑:lol.py中的文件来自此网站,只是修改了url,这就是问题所在:

tesseract_exe_name = 'C:\Users\TyLo\AppData\Local\Tesseract-OCR\tesseract' # Name of executable to be called at command line
请参见那里的
\t
?这是单个制表符,不是反斜杠字符和
t
字符。你只会侥幸逃脱
\U
\T
\A
\L
\T
,因为你很幸运,到你的Python版本问世时,还没有人想到它们的用途。(Python的更高版本实际上使用了
\U

解决方案是执行以下操作之一:

(1) 使用

r'…'
的意思是“不要特别对待反斜杠”

(2) 避开所有的反斜杠:

tesseract_exe_name = 'C:\\Users\\TyLo\\AppData\\Local\\Tesseract-OCR\\tesseract' # Name of executable to be called at command line
在非原始字符串文字中,
\\
表示单个反斜杠,因此
\\t
表示单个反斜杠和
t

(3) 改为使用前斜杠:

tesseract_exe_name = 'C:/Users/TyLo/AppData/Local/Tesseract-OCR/tesseract' # Name of executable to be called at command line
大多数Windows程序都接受正向斜杠。一些不需要,有时您需要一个路径名,该路径名在正向斜杠中是不合法的,但在其他情况下,它是有效的。

这就是问题所在:

tesseract_exe_name = 'C:\Users\TyLo\AppData\Local\Tesseract-OCR\tesseract' # Name of executable to be called at command line
请参见那里的
\t
?这是单个制表符,不是反斜杠字符和
t
字符。你只会侥幸逃脱
\U
\T
\A
\L
\T
,因为你很幸运,到你的Python版本问世时,还没有人想到它们的用途。(Python的更高版本实际上使用了
\U

解决方案是执行以下操作之一:

(1) 使用

r'…'
的意思是“不要特别对待反斜杠”

(2) 避开所有的反斜杠:

tesseract_exe_name = 'C:\\Users\\TyLo\\AppData\\Local\\Tesseract-OCR\\tesseract' # Name of executable to be called at command line
在非原始字符串文字中,
\\
表示单个反斜杠,因此
\\t
表示单个反斜杠和
t

(3) 改为使用前斜杠:

tesseract_exe_name = 'C:/Users/TyLo/AppData/Local/Tesseract-OCR/tesseract' # Name of executable to be called at command line
大多数Windows程序都接受正向斜杠。一些不需要,有时您需要一个路径名,该路径名在正向斜杠中是不合法的,但在其他情况下,它是有效的。

这就是问题所在:

tesseract_exe_name = 'C:\Users\TyLo\AppData\Local\Tesseract-OCR\tesseract' # Name of executable to be called at command line
请参见那里的
\t
?这是单个制表符,不是反斜杠字符和
t
字符。你只会侥幸逃脱
\U
\T
\A
\L
\T
,因为你很幸运,到你的Python版本问世时,还没有人想到它们的用途。(Python的更高版本实际上使用了
\U

解决方案是执行以下操作之一:

(1) 使用

r'…'
的意思是“不要特别对待反斜杠”

(2) 避开所有的反斜杠:

tesseract_exe_name = 'C:\\Users\\TyLo\\AppData\\Local\\Tesseract-OCR\\tesseract' # Name of executable to be called at command line
在非原始字符串文字中,
\\
表示单个反斜杠,因此
\\t
表示单个反斜杠和
t

(3) 改为使用前斜杠:

tesseract_exe_name = 'C:/Users/TyLo/AppData/Local/Tesseract-OCR/tesseract' # Name of executable to be called at command line
大多数Windows程序都接受正向斜杠。一些不需要,有时您需要一个路径名,该路径名在正向斜杠中是不合法的,但在其他情况下,它是有效的。

这就是问题所在:

tesseract_exe_name = 'C:\Users\TyLo\AppData\Local\Tesseract-OCR\tesseract' # Name of executable to be called at command line
请参见那里的
\t
?这是单个制表符,不是反斜杠字符和
t
字符。你只会侥幸逃脱
\U
\T
\A
\L
\T
,因为你很幸运,到你的Python版本问世时,还没有人想到它们的用途。(Python的更高版本实际上使用了
\U

解决方案是执行以下操作之一:

(1) 使用

r'…'
的意思是“不要特别对待反斜杠”

(2) 避开所有的反斜杠:

tesseract_exe_name = 'C:\\Users\\TyLo\\AppData\\Local\\Tesseract-OCR\\tesseract' # Name of executable to be called at command line
在非原始字符串文字中,
\\
表示单个反斜杠,因此
\\t
表示单个反斜杠和
t

(3) 改为使用前斜杠:

tesseract_exe_name = 'C:/Users/TyLo/AppData/Local/Tesseract-OCR/tesseract' # Name of executable to be called at command line


大多数Windows程序都接受正向斜杠。有一些不需要,有时你需要一个
\.\.
路径名,该路径名在正斜杠中是不合法的,但在其他情况下,它是有效的。

答案很好,但是#2中缺少了双反斜杠。也许四元转义会出现在标记中?@tdelaney:出于某种原因,它没有将这些代码块显示为代码块。也许把它们放在有编号的街区里会让人困惑?我会设法解决它…@tdelaney:我想不出来,所以我只是伪造了编号列表,现在它可以工作了。:)哦,我没想到,谢谢你!这就是我的问题的解决方案:)但它不会打印我作为字符串发送给他的验证码,这很奇怪。好吧,我明白,我会先尝试自己解决:)再次感谢你的帮助。回答得很好,但#2中缺少了双反斜杠。也许四元转义会出现在标记中?@tdelaney:出于某种原因,它没有将这些代码块显示为代码块。也许把它们放在有编号的街区里会让人困惑?我会设法解决它…@tdelaney:我想不出来,所以我只是伪造了编号列表,现在它可以工作了。:)哦,我没想到,谢谢你!这就是我的问题的解决方案:)但它不会打印我作为字符串发送给他的验证码,这很奇怪。好吧,我明白,我会先尝试自己解决:)再次感谢你的帮助。回答得很好,但#2中缺少了双反斜杠。也许quad会在标记中逃逸?@tdelaney:F