安装pypyp3的opencv

ruoxqz4g  于 2022-11-15  发布在  其他
关注(0)|答案(2)|浏览(294)

我 已经 在 Mac 上 安装 了 pypy3 , 并 想 用 它 来 加速 python 脚本 来 分析 实时 视频 源 。 我 尝试 用 pip 和 pip_pypy3 安装 opencv-python , 但 得到 以下 错误 :

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

中 的 每 一 个
有 什么 想法 我 可以 绕 过 这个 错误 吗 ? 谢谢 !
(The以前 有 过 这个 问题 的 人 的 建议 相当 令 人 困惑 ... )

rkttyhzu

rkttyhzu1#

您是如何尝试安装opencv的?如果您在Mac中,请尝试使用此完整路径

pip install opencv-python==4.5.3.56
jgovgodb

jgovgodb2#

opencv-python没有为PyPy发布二进制wheels,所以你要自己编译它,这不是小事。我推荐using conda-forge,因为那里有更多的二进制包可用。如果你愿意,你可以礼貌地在opencv-python问题跟踪器上要求this issue上的PyPy wheels。
如果你的代码使用opencv,那么PyPy不太可能更快。为了支持CPython C-API,PyPy needs to emulate C,所以每个函数调用的速度大约是CPython C-API的4倍,当然,JIT不能查看编译后的C/C++代码。如果你的代码是纯python,PyPy可能会有所帮助,这个sobel filter in python就是我十多年前参与PyPy的原因。

相关问题