0
0

EasyOCRインストール時の注意点(2024/6以降)

Last updated at Posted at 2024-07-22

はじめに

先日(2024/7)新しく構築した環境でEasyOCRを使ったプログラムがなぜか動かなかった(既存環境ならちゃんと動く)。調べたところ、EasyOCRが依存パッケージのバージョンアップについていけていないようなのでまとめた。

環境

  • EasyOCR 1.7.1
  • Python 3.9.13 / Python 3.12.4 (両方ともMicrosoft Store版)
  • Windows 10 Pro (64bit) 22H2

状況

EasyOCRを使ったプログラムを実行すると次の2種類のメッセージが出て、プログラムが異常終了する

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.
ModuleNotFoundError: No module named 'bidi.algorithm'

原因

EasyOCRが依存パッケージのバージョンアップに対応できていない

  • numpy 2.0.0(2024/6/16リリース)
  • python-bidi 0.5.0 (2024/7/21リリース)

numpy, python-bidiモジュールのバージョンを確認するコマンド

python3 -m pip show numpy python-bidi

動作を確認できたのは次のバージョン

  • numpy 1.26.4
  • python-bidi 0.4.2

解決方法

EasyOCRインストール前に旧バージョンの依存パッケージを先にインストールしてしまうのが簡単

python3 -m pip install "numpy<2.0" "python-bidi<0.5"
python3 -m pip install easyocr

すでにEasyOCRをインストールして新しいnumpy,python-bidiモジュールがインストールされてしまっているのであれば、numpy,python-bidiをバージョンダウンすればよい

python3 -m pip install --upgrade "numpy<2.0"
python3 -m pip install --upgrade "python-bidi<0.5"

install --upgradeコマンドでバージョンダウンも可能

(追記:2024/7/24)

python-bidiのバージョンが0.5.1になって、python-bidiについてはエラーが発生しなくなった模様。したがって、

  • EasyOCRが未インストールの場合
python3 -m pip install "numpy<2.0"
python3 -m pip install easyocr
  • EasyOCRがインストール済みの場合
python3 -m pip install --upgrade "numpy<2.0"

参考情報

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0