1
img = printscreen_pil
img = img.filter(ImageFilter.MedianFilter())
enhancer = ImageEnhance.Contrast(img)
img = enhancer.enhance(2)
img = img.convert('1')
img.save('temp.jpg')
text = pytesseract.image_to_string(Image.open('temp.jpg'))
私はイメージをテキストに変換するためにイメージを読んでいますが、エラーが発生しました。指定されたファイルが見つかりません。私はそれがPythonの作業ディレクトリと関係していると思います。これが愚かな質問であれば申し訳ありませんが、私があなたを助けてくれることを願っています。FileNotFoundError on Python
これは完全なエラーです。mssg。
Traceback (most recent call last):
File "C:\Users\pncor\Documents\pyprograms\bot.py", line 23, in <module>
text = pytesseract.image_to_string(Image.open('temp.jpg'))
File "C:\Users\pncor\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string
config=config)
File "C:\Users\pncor\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "C:\Users\pncor\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Users\pncor\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 990, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
とスクリプトが同じディレクトリにあるはず... –
エラーはかなり明白です。あなたの写真がPythonスクリプトと同じディレクトリにあるかどうかを確認してください。それを比較的参照してください。 – Vinny
完全なエラーを投稿し、それを引き起こす行を示してください。私はそれが "1"という名前のファイルを見つけられていないので、エラーを引き起こすのは "img.convert( '1')"の行だと推測しています。たぶんそれは実際には「1.jpg」なのでしょうか?しかし、私は不十分な情報で推測しています。 –