在nvidia ngc平台下载docker image,根据实验要求在环境里安装opencv。因为当前实验tensorflow要求版本较低,我下载了比较久远的版本镜像。如果大家是自己复现代码,还是使用尽可能新的环境,则可以避免大部分环境问题。

通过pip安装opencv,指令如下:

pip install opencv-python

安装过程的输出:

Collecting opencv-python
  Downloading https://files.pythonhosted.org/packages/77/f5/49f034f8d109efcf9b7e98fbc051878b83b2f02a1c73f92bbd37f317288e/opencv-python-4.4.0.42.tar.gz (88.9MB)
    100% |████████████████████████████████| 88.9MB 919kB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Requirement already satisfied: numpy>=1.13.1 in /usr/local/lib/python3.5/dist-packages (from opencv-python) (1.14.5)
Building wheels for collected packages: opencv-python
  Building wheel for opencv-python (PEP 517) ...

PEP 517信息出现后,过了很长时间,出现报错信息:

Configuring Project
    Working directory:
      /tmp/pip-install-zujf20md/opencv-python/_skbuild/linux-x86_64-3.6/cmake-build
    Command:
      cmake /tmp/pip-install-zujf20md/opencv-python/opencv -G 'Unix Makefiles' -DCMAKE_INSTALL_PREFIX:PATH=/tmp/pip-install-zujf20md/opencv-python/_skbuild/linux-x86_64-3.6/cmake-install -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python -DPYTHON_VERSION_STRING:STRING=3.6.8 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.6m -DPYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.6m.so -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/tmp/pip-build-env-tr73ewqw/overlay/lib/python3.6/site-packages/skbuild/resources/cmake -DPYTHON3_EXECUTABLE=/usr/bin/python -DPYTHON3_INCLUDE_DIR=/usr/include/python3.6m -DPYTHON3_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6m.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 -DCMAKE_BUILD_TYPE:STRING=Release
  Copying files from CMake output
  Traceback (most recent call last):
    File "/usr/local/lib/python3.6/dist-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
      main()
    File "/usr/local/lib/python3.6/dist-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/usr/local/lib/python3.6/dist-packages/pip/_vendor/pep517/_in_process.py", line 141, in build_wheel
      metadata_directory)
    File "/usr/local/lib/python3.6/dist-packages/setuptools/build_meta.py", line 209, in build_wheel
      wheel_directory, config_settings)
    File "/usr/local/lib/python3.6/dist-packages/setuptools/build_meta.py", line 194, in _build_with_temp_dir
      self.run_setup()
    File "/usr/local/lib/python3.6/dist-packages/setuptools/build_meta.py", line 237, in run_setup
      self).run_setup(setup_script=setup_script)
    File "/usr/local/lib/python3.6/dist-packages/setuptools/build_meta.py", line 142, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 496, in <module>
      main()
    File "setup.py", line 289, in main
      cmake_source_dir=cmake_source_dir,
    File "/tmp/pip-build-env-tr73ewqw/overlay/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 629, in setup
      cmake_source_dir, skbuild_kw['cmake_install_dir'])
    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-python
  Running setup.py clean for opencv-python
Failed to build opencv-python
ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly

升级pip工具包:

pip install --upgrade pip setuptools wheel

重试安装:

pip install opencv-python

问题解决啦~!

Package | 解决 Could not build wheels for opencv-python which use PEP 517 and cannot be installed 背景在nvidia ngc平台下载docker image,根据实验要求在环境里安装opencv。因为当前实验tensorflow要求版本较低,我下载了比较久远的版本镜像。如果大家是自己复现代码,还是使用尽可能新的环境,则可以避免大部分环境问题。问题通过pip安装opencv,指令如下:pip install opencv-python安装过程的输出:Collecting opencv-python Downloading https://files.pythonhosted.org/pa
安装opencv时报错:Could not build wheels for opencv-python which use PEP 517 and cannot be installed direc
一、问题背景 最近写一批程序,需要用到opencv里面的函数,但是导入cv2的时候,新电脑提示没有安装,所以首先安装opencv的库,直接pip install opencv-python,不过报错了。 然后从镜像站中安装opencv,直接pip install -i https://mirrors.aliyun.com/pypi/simple opencv-python,不过仍然报错,报错原因和上一次一样:Could not build wheels for openc...
pip install --upgrade -r requirements.txt -i https://mirror.baidu.com/pypi/simple Looking in indexes: https://mirror.baidu.com/pypi/simple Collecting prettytable Downloading https://mirror.baidu.com/pypi/packages/5f/ab/64371af206988d7b15c8112c9c277b8eb4618
Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly
Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly 直接运用conda安装: 随后完成cv2的安装。
pip install opencv-python时遇到如下问题:ERROR-Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly 解决方案: pip install opencv-python --no-use-pep517 × pip install opencv-python --no-cache-dir √ 版本信息: Ubuntu:20.04 python:3.
Package | 解决 Could not build wheels for opencv-python which use PEP 517 and cannot be installed 35359 Package | 解决 ImportError: libGL.so.1: cannot open shared object file: No such file or directory 26470 Package | 解决 ImportError: libGL.so.1: cannot open shared object file: No such file or directory 山居秋暝LS: 非常感谢,困扰了好久的问题。 Package | 解决 module ‘cv2‘ has no attribute ‘gapi_wip_gst_GStreamerPipeline‘ 一月σண: 谢谢,有用 Matlab | mex混编多个cpp文件 weixin_42674476: 大佬,编译的c文件调用cuda的.cu文件应该如何编译,如何书写语法呢? Package | 解决 Windows10 Anaconda环境 CUDA11.5 pytorch运行报错 No CUDA runtime is found 1LOVESJohnny: CUDA版本、cudnn版本对齐了吗