PaddleOCR Error flag 'flagfile' was defined more than once

966 Views Asked by At

Am encountering an issue running PaddleOCR on M1 Macbook

ERROR: flag 'flagfile' was defined more than once (in files '/Users/paddle/xly/workspace/f2bafd01-b80e-4ac8-972c-1652775b2e51/Paddle/build/third_party/gflags/src/extern_gflags/src/gflags.cc' and '/tmp/gflags-20211021-3963-1mi18ai/gflags-2.2.2/src/gflags.cc').

2

There are 2 best solutions below

0
On

MAC M1 chip can't follow Paddle's document step by step. I solve it by downloading the source code and recompiling it https://juejin.cn/post/7189617837424672805

0
On

This is related to the new version 2.6. With 2.5 you can use the wheel with the M1 (maybe you will need to debug some of the dependencies).

The good news is I've just installed PaddleOCR 2.6.1.2 on my Mac, right now.

You have two options:

  1. You can upgrade to Python 3.10 (I am using 3.10.8) and then this error is gone
  2. You can stick to Python 3.9 or lower and install PaddleOCR manually

If you want to continue with Python 3.9 or lower, then instead of installing via pip or conda, you do it manually by building the egg locally (it is an egg and not a wheel because it is using setuptools).

Assuming you already have a conda env or similar (mine has Python 3.10 and paddlepaddle 4.2.1, you'll probably need to install setuptools), you proceed as follows:

git clone https://github.com/PaddlePaddle/PaddleOCR.git
cd PaddleOCR
conda install --file requirements.txt
python setup.py install

After this you can use PaddleOCR on that environment.

Dependencies that can bring on some issues are Shapely, PyMuPDF, protobuf... Anyway I believe this whole issue will be fixed in the next release and then we will be able to use the wheel as-is.