0
pytesseract
을 사용하여 이미지를 파이썬 텍스트로 읽습니다. 이 코드는 파일 image.png
를 얻을 수FileNotFoundError : [WinError 2] pytesseract python-3.x를 사용하는 동안 지정된 파일을 찾을 수 없습니다.
from PIL import Image
from pytesseract import image_to_string
import os.path
if (os.path.exists('image.png')):
filename = 'image.png'
image = Image.open(filename)
image.show()
s = image_to_string(Image.open(filename))
else:
print('Does not exist')
이 그것을 열고 파일이 해당 디렉토리에 존재 의미 나 이미지를 보여 다음은 내 코드입니다. 그러나 다음 줄로 가면 s = image_to_string(Image.open(filename))
다음과 같은 오류가 발생합니다.
Traceback (most recent call last):
File "C:/Users/hp/Desktop/GII/Genetic_Algorithm.py", line 8, in <module>
s = image_to_string(Image.open(filename))
File "C:\Users\hp\Downloads\WinPython-64bit-3.5.1.2\python-3.5.1.amd64\lib\site-packages\pytesseract\pytesseract.py", line 161, in image_to_string
config=config)
File "C:\Users\hp\Downloads\WinPython-64bit-3.5.1.2\python-3.5.1.amd64\lib\site-packages\pytesseract\pytesseract.py", line 94, in run_tesseract
stderr=subprocess.PIPE)
File "C:\Users\hp\Downloads\WinPython-64bit-3.5.1.2\python-3.5.1.amd64\lib\subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "C:\Users\hp\Downloads\WinPython-64bit-3.5.1.2\python-3.5.1.amd64\lib\subprocess.py", line 1220, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
나는 열심히 노력했지만 어떻게 처리해야할지 모르겠다.
동일한 오류가 다시 발생합니다. PIL은 Image.open (filename)을 사용하여 이미지를 열 수 있기 때문에 PIL이 문제가되지 않지만 위의 오류가 표시되면'pytesseract'를 사용할 때 발생합니다. – muazfaiz
다른 아이디어; 파일을 두 번 열면 두 번째로 파일을 사용할 수 없습니다. 그래서, 아마도 "s = image_to_string (image)"시도해보십시오. – stonebig
나는 당신이 말하고자하는 것을 정확히 얻지 못했습니다. 생각해도 파일을 두 번 열면 경로 문제가 변경되지 않습니다. 당신은 직감을 써주시겠습니까? 감사합니다 – muazfaiz