首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >未能为Opencv构建车轮

未能为Opencv构建车轮
EN

Stack Overflow用户
提问于 2022-04-14 10:47:40
回答 1查看 4.6K关注 0票数 5

我用下面的命令将轮子、pip和setuptools升级到最新版本。

pip3.9 install --upgrade pip setuptools wheel

当我尝试安装opencv pip3.9 install opencv-python时,会出现一个错误。我试着安装一个旧版本,得到了相同的错误(4.5.5.62)。这是我遇到的错误,请看一看,谢谢!

Python版本: 3.9 (opencv-python在3.8岁时工作)

应用: PyCharm

代码语言:javascript
运行
复制
Traceback (most recent call last):
        File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 261, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
        File "/private/var/folders/0v/j0nhw8p50yd3_w61mysphgjc0000gn/T/pip-build-env-rp7pv38q/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 244, in build_wheel
          return self._build_with_temp_dir(['bdist_wheel'], '.whl',
        File "/private/var/folders/0v/j0nhw8p50yd3_w61mysphgjc0000gn/T/pip-build-env-rp7pv38q/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 229, in _build_with_temp_dir
          self.run_setup()
        File "/private/var/folders/0v/j0nhw8p50yd3_w61mysphgjc0000gn/T/pip-build-env-rp7pv38q/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 281, in run_setup
          super(_BuildMetaLegacyBackend,
        File "/private/var/folders/0v/j0nhw8p50yd3_w61mysphgjc0000gn/T/pip-build-env-rp7pv38q/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 174, in run_setup
          exec(compile(code, __file__, 'exec'), locals())
        File "setup.py", line 502, in <module>
          main()
        File "setup.py", line 239, in main
          skbuild.setup(
        File "/private/var/folders/0v/j0nhw8p50yd3_w61mysphgjc0000gn/T/pip-build-env-rp7pv38q/overlay/lib/python3.9/site-packages/skbuild/setuptools_wrap.py", line 676, in setup
          _classify_installed_files(
        File "setup.py", line 442, in _classify_installed_files_override
          return (cls.wraps._classify_installed_files)(
      TypeError: _classify_installed_files() got an unexpected keyword argument 'cmake_install_dir'
      [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
EN

回答 1

Stack Overflow用户

发布于 2022-09-16 14:40:04

通过检查函数cls.wraps._classify_installed_files的源。

代码语言:javascript
运行
复制
print(inspect.getsource(cls.wraps._classify_installed_files))

我发现原因是函数定义中没有名为cmake_install_dir的参数,而是_cmake_install_dir参数。

代码语言:javascript
运行
复制
def _classify_installed_files(
    install_paths,
    package_data,
    package_prefixes,
    py_modules,
    new_py_modules,
    scripts,
    new_scripts,
    data_files,
    cmake_source_dir,
    _cmake_install_dir,
):
    assert not os.path.isabs(cmake_source_dir)
    assert cmake_source_dir != "."

    install_root = os.path.join(os.getcwd(), CMAKE_INSTALL_DIR())
    ......

因此,我将命名参数cmake_install_dir更改为_cmake_install_dir。然后通过了!

代码语言:javascript
运行
复制
return (cls.wraps._classify_installed_files)(
            final_install_paths,
            package_data,
            package_prefixes,
            py_modules,
            new_py_modules,
            scripts,
            new_scripts,
            data_files,
            # To get around a check that prepends source dir to paths and breaks package detection code.
            cmake_source_dir="",
            _cmake_install_dir=cmake_install_reldir,
        )
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71870382

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档