I've installed pypy3 on Mac, and would like to use it to speed up a python script to analyse a live video feed. I've tried to install opencv-python with pip and pip_pypy3, but get the following error:
Building wheels for collected packages: opencv-python
Building wheel for opencv-python (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for opencv-python (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [9 lines of output]
Traceback (most recent call last):
File "/private/var/folders/7v/1cg_j6kd34l4k8zgvj782ndc0000gn/T/pip-build-env-nymhzjmp/overlay/site-packages/skbuild/setuptools_wrap.py", line 612, in setup
cmkr = cmaker.CMaker(cmake_executable)
File "/private/var/folders/7v/1cg_j6kd34l4k8zgvj782ndc0000gn/T/pip-build-env-nymhzjmp/overlay/site-packages/skbuild/cmaker.py", line 148, in __init__
self.cmake_version = get_cmake_version(self.cmake_executable)
File "/private/var/folders/7v/1cg_j6kd34l4k8zgvj782ndc0000gn/T/pip-build-env-nymhzjmp/overlay/site-packages/skbuild/cmaker.py", line 105, in get_cmake_version
) from err
Problem with the CMake installation, aborting build. CMake executable is cmake
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for opencv-python
Failed to build opencv-python
ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects
Any idea how I can get around this error? Thanks!
(The advice from people who have previously had this problem is rather confusing...)
CodePudding user response:
How did you tried to install opencv?. Try this full path if you are in Mac
pip install opencv-python==4.5.3.56
CodePudding user response:
opencv-python does not release binary wheels for PyPy, so you are on your own to compile it, which is non-trivial. I would recommend using conda-forge instead since there are many more binary packages available there. If you want, you could ask politely for PyPy wheels on this issue on the opencv-python issue tracker.
With that, PyPy is unlikely to be faster if much of your code uses opencv. In order to support the CPython C-API, PyPy needs to emulate C so each function call is about 4x slower, and of course the JIT cannot look inside compiled C/C code. If your code is pure python, PyPy may be able to help, this sobel filter in python is what got me involved in PyPy over a decade ago.