0

这里是 Linux 新手。在 Linux Mint、python 3.8、Anaconda 下,尝试通过以下方式安装 opencv-contrib-python

pip install --no-binary opencv-contrib-python opencv-contrib-python

经过漫长且非常耗费资源的过程后,出现此错误。关于我所缺少的任何建议?附带说明一下,没有--no-binary 的正常 pip 安装工作正常,但会导致运行时错误,我试图根据这篇文章解决。

  Configuring Project
    Working directory:
      /tmp/pip-install-cwq7rmvu/opencv-contrib-python/_skbuild/linux-x86_64-3.8/cmake-build
    Command:
      cmake /tmp/pip-install-cwq7rmvu/opencv-contrib-python/opencv -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=/tmp/pip-install-cwq7rmvu/opencv-contrib-python/_skbuild/linux-x86_64-3.8/cmake-install -DPYTHON_EXECUTABLE:FILEPATH=/home/artem/anaconda3/bin/python -DPYTHON_VERSION_STRING:STRING=3.8.5 -DPYTHON_INCLUDE_DIR:PATH=/home/artem/anaconda3/include/python3.8 -DPYTHON_LIBRARY:FILEPATH=/home/artem/anaconda3/lib/libpython3.8.so -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/tmp/pip-build-env-p4glm5l9/overlay/lib/python3.8/site-packages/skbuild/resources/cmake -DPYTHON3_EXECUTABLE=/home/artem/anaconda3/bin/python -DPYTHON3_INCLUDE_DIR=/home/artem/anaconda3/include/python3.8 -DPYTHON3_LIBRARY=/home/artem/anaconda3/lib/libpython3.8.so -DBUILD_opencv_python3=ON -DBUILD_opencv_python2=OFF -DBUILD_opencv_java=OFF -DOPENCV_PYTHON3_INSTALL_PATH=python -DINSTALL_CREATE_DISTRIB=ON -DBUILD_opencv_apps=OFF -DBUILD_opencv_freetype=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_DOCS=OFF -DOPENCV_EXTRA_MODULES_PATH=/tmp/pip-install-cwq7rmvu/opencv-contrib-python/opencv_contrib/modules -DCMAKE_BUILD_TYPE:STRING=Release
  
  Copying files from CMake output
  Traceback (most recent call last):
    File "/home/artem/anaconda3/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
      main()
    File "/home/artem/anaconda3/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/home/artem/anaconda3/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 204, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
    File "/tmp/pip-build-env-p4glm5l9/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 221, in build_wheel
      return self._build_with_temp_dir(['bdist_wheel'], '.whl',
    File "/tmp/pip-build-env-p4glm5l9/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 207, in _build_with_temp_dir
      self.run_setup()
    File "/tmp/pip-build-env-p4glm5l9/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 258, in run_setup
      super(_BuildMetaLegacyBackend,
    File "/tmp/pip-build-env-p4glm5l9/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 150, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 496, in <module>
      main()
    File "setup.py", line 248, in main
      skbuild.setup(
    File "/tmp/pip-build-env-p4glm5l9/overlay/lib/python3.8/site-packages/skbuild/setuptools_wrap.py", line 625, in setup
      _classify_installed_files(cmake_manifest, package_data, package_prefixes,
    File "setup.py", line 381, in _classify_installed_files_override
      with open('scripts/__init__.py', 'r') as custom_init:
  FileNotFoundError: [Errno 2] No such file or directory: 'scripts/__init__.py'
  ----------------------------------------
  ERROR: Failed building wheel for opencv-contrib-python
Failed to build opencv-contrib-python
ERROR: Could not build wheels for opencv-contrib-python which use PEP 517 and cannot be installed directly
4

1 回答 1

2

删除 Anaconda 并使用我的 Linux 发行版提供的 python 解决了这个问题。

于 2021-11-04T16:11:53.580 回答