概要
以下コードをpyinstallerでexe化後、作成されたexeを実行すると、
Running from container, but no tessdata (C:\Users\<ユーザー名>\AppData\Local\Temp_MEI280202\data) found !
Running from container, but no tesseract (C:\Users\<ユーザー名>\AppData\Local\Temp_MEI280202\tesseract) found !
というエラーが出る。
このエラーが原因で、別のプログラム(本プログラムとは別)のpyocrが正常に動作しない為、このエラーを解消したいのですが、どうすればいいか手詰まりです。
尚、開発環境でのデバッグ時はこのエラーは出ず、またpyocrも正常に動作します。
cmd
1C:<省略>>pyinstaller sample_pyocr_test.py
確認した事
・OS再起動後、実行
・開発環境ではエラー出ず
・C:\Users\<ユーザー名>\AppData\Local\Tempを確認すると、フォルダ_MEI280202は存在しない
→フォルダ_MEI280202はプログラム実行時に生成されますが、プログラム終了と同時に削除されます。
存在しないのは、_MEI280202配下の\data及び\tesseractです。
・コマンドプロンプトで以下コマンドを実行してtesseractのパスを確認
cmd
1C:>where tesseract 2C:\Program Files (x86)\Tesseract-OCR\tesseract.exe
環境
python ver:3.6.6.amd64
OS:Windows 10Pro
WinPython Spyder※
※pyinstaller実行時はWindowsのCommand Promptにて実行)
tesseractのバージョン
cmd
1C:>tesseract -v 2tesseract v4.0.0.20181030 3 leptonica-1.76.0 4 libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 1.5.3) : libpng 1.6.34 : libtiff 4.0.9 : zlib 1.2.11 : libwebp 0.6.1 : libopenjp2 2.2.0 5
参考
Tesseract のインストール方法は以下を参考にしました。
https://www.kunihikokaneko.com/dblab/licenseplate/tesseract.html
コード
python
1import pyocr 2import pyocr.builders 3import os 4import time 5 6if __name__ == "__main__": 7 8 #PyOCRインストールチェック 9 tools = pyocr.get_available_tools() 10 if len(tools) == 0: 11 print("No OCR tool found") 12 tool = tools[0] 13 14 langs = tool.get_available_languages() 15 print("pyocr lang: {}".format(langs)) 16 print("pyocr Ver:{}".format(tool.get_version())) 17 18 #環境変数確認 19 print("TESSDATA_PREFIX:{}".format(os.environ['TESSDATA_PREFIX'])) 20 21 env =os.environ['Path'] 22 envs = env.split(";") 23 24 for i in envs: 25 print("Path{}".format(i))
cmd
1Running from container, but no tessdata (C:\Users\<ユーザー名>\AppData\Local\Temp\_MEI280202\data) found ! 2Running from container, but no tessdata (C:\Users\<ユーザー名>\AppData\Local\Temp\_MEI280202\data) found ! 3Running from container, but no tesseract (C:\Users\<ユーザー名>\AppData\Local\Temp\_MEI280202\tesseract) found ! 4Running from container, but no tessdata (C:\Users\<ユーザー名>\AppData\Local\Temp\_MEI280202\data) found ! 5Running from container, but no tesseract (C:\Users\<ユーザー名>\AppData\Local\Temp\_MEI280202\tesseract) found ! 6pyocr lang: ['eng', 'jpn', 'osd', 'script/Japanese', 'script/Japanese_vert'] 7Running from container, but no tessdata (C:\Users\<ユーザー名>\AppData\Local\Temp\_MEI280202\data) found ! 8Running from container, but no tesseract (C:\Users\<ユーザー名>\AppData\Local\Temp\_MEI280202\tesseract) found ! 9pyocr Ver:(4, 0, 0) 10TESSDATA_PREFIX:C:\Program Files (x86)\Tesseract-OCR\tessdata 11 12<省略> 13PathC:\Program Files (x86)\Tesseract-OCR
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。