webmaster-kazu.com

テクノロジー・データ分析・実践ログ・その他

GoogleのTesseract-OCRのPython ラッパー「pytesseract」のインストール

カテゴリ: Python【初歩から現場実務的なもの】

GoogleのTesseract-OCRのPython ラッパー「pytesseract」のインストールについて解説しています。

「pytesseract(https://github.com/madmaze/pytesseract)」は、Python用の光学式文字認識 (OCR) ツールで、GoogleのTesseract-OCR Engine のラッパーです。jpeg、png、gif、bmp、tiff など、PillowおよびLeptonicaの画像ライブラリでサポートされているすべての画像タイプを読み取ることができる。

■Python

今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows10)(pythonランチャーでの確認)

■pytesseractをインストールする

pytesseractをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install pytesseract

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、バージョンの切り替えを行います。

py -3.8 -m pip install pytesseract

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable

Collecting pytesseract

Downloading pytesseract-0.3.10-py3-none-any.whl (14 kB)

Collecting packaging>=21.3

Using cached packaging-22.0-py3-none-any.whl (42 kB)

Collecting Pillow>=8.0.0

Using cached Pillow-9.3.0-cp38-cp38-win_amd64.whl (2.5 MB)

Installing collected packages: Pillow, packaging, pytesseract

Successfully installed Pillow-9.3.0 packaging-22.0 pytesseract-0.3.10

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、pytesseractが正常にインストールされたことになります。

なお、今回はpytesseractのバージョン0.3.10をインストールしました。