###前提・実現したいこと
pytesseractを用いて、画像から数字を読み取り出力しようとしています
###発生している問題・エラーメッセージ
runfile('C:/Users/(ユーザー名)/.spyder-py3/自作コード/おためし.py', wdir='C:/Users/(ユーザー名)/.spyder-py3/自作コード') Traceback (most recent call last): File "<ipython-input-2-629fea9ac1e7>", line 1, in <module> runfile('C:/Users/(ユーザー名)/.spyder-py3/自作コード/おためし.py', wdir='C:/Users/(ユーザー名)/.spyder-py3/自作コード') File "C:\Users(ユーザー名)\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile execfile(filename, namespace) File "C:\Users(ユーザー名)\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfile exec(compile(f.read(), filename, 'exec'), namespace) File "C:/Users/(ユーザー名)/.spyder-py3/自作コード/おためし.py", line 6, in <module> number = pytesseract.image_to_string(img) File "C:\Users(ユーザー名)\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string config=config) File "C:\Users(ユーザー名)\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract proc = subprocess.Popen(command, stderr=subprocess.PIPE) File "C:\Users(ユーザー名)\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 209, in __init__ super(SubprocessPopen, self).__init__(*args, **kwargs) File "C:\Users(ユーザー名)\Anaconda3\lib\subprocess.py", line 665, in __init__ errread, errwrite) = self._get_handles(stdin, stdout, stderr) File "C:\Users(ユーザー名)\Anaconda3\lib\subprocess.py", line 916, in _get_handles c2pwrite = self._make_inheritable(c2pwrite) File "C:\Users(ユーザー名)\Anaconda3\lib\subprocess.py", line 948, in _make_inheritable _winapi.DUPLICATE_SAME_ACCESS) OSError: [WinError 6] ハンドルが無効です。
###該当のソースコード
python
1import pytesseract 2from PIL import Image 3 4url_img = 'screen.png' 5img = Image.open(url_img) 6number = pytesseract.image_to_string(img) 7print(number)
###試したこと
tesseractをコマンドプロンプトで実行したところ、やりたいことが実現できました
また、tesseract、pytesseract、PILはインストール済みです
###補足情報(言語/FW/ツール等のバージョンなど)
Spyder(python3.6)を使っています
OSはwindows7です
tesseract-ocrのバージョンは3.05.01です
ソースコードは某サイト様からお借りしています
あなたの回答
tips
プレビュー