PaddlePaddle / PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Apple Mac M1 install problems

ah161652 opened this issue · comments

  • System Environment:Apple M1 Processor, Python 3.9.13
  • Version:Paddle: 2.3.0 PaddleOCR: 2.5.0

Installation of PaddleOCR via Pip does not work on Mac M1 devices. The error comes from building the opencv-contrib-python-4.4.0.46 wheel. I believe this is due to this version of opencv being incompatible with Mac m1 devices, which has been fixed in more recent versions of opencv.

Can this be changed for PaddleOCR by changing the dependency to a newer opencv version?

Thanks.

ERROR: Failed building wheel for numpy
Failed to build numpy
ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects

After tinkering around it with some more. I think the hard pinned dependency on opencv-contrib-python is causing a lot of problem

❯ pip install opencv-contrib-python
Collecting opencv-contrib-python
  Downloading opencv_contrib_python-4.6.0.66-cp37-abi3-macosx_11_0_arm64.whl (38.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 38.9/38.9 MB 28.1 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.14.5 in ./.venv/lib/python3.9/site-packages (from opencv-contrib-python) (1.23.0)
Installing collected packages: opencv-contrib-python
Successfully installed opencv-contrib-python-4.6.0.66

but when I try to use the version that is pinned 4.4.0.46 is it causing build to fail.

 pip install opencv-contrib-python==4.4.0.46
Collecting opencv-contrib-python==4.4.0.46
  Downloading opencv-contrib-python-4.4.0.46.tar.gz (148.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 148.8/148.8 MB 22.8 MB/s eta 0:00:00
  Installing build dependencies ... \
.....
                impl_tag, abi_tag, plat_tag = self.get_tag()
              File "/private/var/folders/sh/yv_yy1f55t352j55wrvwzwsc0000gq/T/pip-build-env-m3tewjjj/overlay/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 252, in get_tag
                plat_name = get_platform(self.bdist_dir)
              File "/private/var/folders/sh/yv_yy1f55t352j55wrvwzwsc0000gq/T/pip-build-env-m3tewjjj/overlay/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 48, in get_platform
                result = calculate_macosx_platform_tag(archive_root, result)
              File "/private/var/folders/sh/yv_yy1f55t352j55wrvwzwsc0000gq/T/pip-build-env-m3tewjjj/overlay/lib/python3.9/site-packages/wheel/macosx_libfile.py", line 356, in calculate_macosx_platform_tag
                assert len(base_version) == 2
            AssertionError
            [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
        ERROR: Failed building wheel for numpy
      Failed to build numpy
      ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

After tinkering around it with some more. I think the hard pinned dependency on opencv-contrib-python is causing a lot of problem

❯ pip install opencv-contrib-python
Collecting opencv-contrib-python
  Downloading opencv_contrib_python-4.6.0.66-cp37-abi3-macosx_11_0_arm64.whl (38.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 38.9/38.9 MB 28.1 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.14.5 in ./.venv/lib/python3.9/site-packages (from opencv-contrib-python) (1.23.0)
Installing collected packages: opencv-contrib-python
Successfully installed opencv-contrib-python-4.6.0.66

but when I try to use the version that is pinned 4.4.0.46 is it causing build to fail.

 pip install opencv-contrib-python==4.4.0.46
Collecting opencv-contrib-python==4.4.0.46
  Downloading opencv-contrib-python-4.4.0.46.tar.gz (148.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 148.8/148.8 MB 22.8 MB/s eta 0:00:00
  Installing build dependencies ... \
.....
                impl_tag, abi_tag, plat_tag = self.get_tag()
              File "/private/var/folders/sh/yv_yy1f55t352j55wrvwzwsc0000gq/T/pip-build-env-m3tewjjj/overlay/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 252, in get_tag
                plat_name = get_platform(self.bdist_dir)
              File "/private/var/folders/sh/yv_yy1f55t352j55wrvwzwsc0000gq/T/pip-build-env-m3tewjjj/overlay/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 48, in get_platform
                result = calculate_macosx_platform_tag(archive_root, result)
              File "/private/var/folders/sh/yv_yy1f55t352j55wrvwzwsc0000gq/T/pip-build-env-m3tewjjj/overlay/lib/python3.9/site-packages/wheel/macosx_libfile.py", line 356, in calculate_macosx_platform_tag
                assert len(base_version) == 2
            AssertionError
            [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
        ERROR: Failed building wheel for numpy
      Failed to build numpy
      ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

Yes exactly the same issue here ( closed issue by accident , apologies )

commented

我是mac m1 pro, 安装paddleOCR>=2.0.1就会报错,导致我只能用OCR1.1.1版本,具体错误与https://github.com/PaddlePaddle/PaddleOCR/issues/6720#issuecomment-1177599762 相同

A workaround which works on my M1 Mac:

  • Download source code locally
  • In requirements.txt, update to opencv-contrib-python==4.6.0.66
  • Pip install -r requirements.txt
  • python setup.py install

This works for me, via installing via setup.py rather than pip.

It would be useful for this change to be introduced to the code so Mac M1 users can install PaddleOCR from pip though.

commented

A workaround which works on my M1 Mac:

  • Download source code locally
  • In requirements.txt, update to opencv-contrib-python==4.6.0.66
  • Pip install - r requirements.txt
  • python setup.py install

This works for me, via installing via setup.py rather than pip.

It would be useful for this change to be introduced to the code so Mac M1 users can install PaddleOCR from pip though.

Unuseful for me, I'm M1 Pro, I can't via this method to use PaddleOCR 2.5, Thanks.

commented

Ok, fine. In requirements.txt, update to opencv-contrib-python and python3 setup.py install, Success!

currently blocked by this. Can we have PR to upgrade opencv Can #6215 be merged

The 2.6 branch no longer restricts the opencv version number. Try it!