本文主要是介绍python安装opencv出错 PEP 517,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
我的 python 版本是 3.6 的,当需要安装 opencv 时,使用pip install opencv-python
命令进行安装时,出现错误,如下所示:
Building Custom Rule C:/Users/liqian/AppData/Local/Temp/pip-install-6jpavinn/opencv-python_4bf9b16580254d7190cb574ec2fc8790/opencv/modules/imgproc/CMakeLists.txtimgwarp.avx2.cppresize.avx2.cppaccum.avx2.cppbilateral_filter.avx2.cppbox_filter.avx2.cppfilter.avx2.cppcolor_hsv.avx2.cppcolor_rgb.avx2.cppcolor_yuv.avx2.cppmedian_blur.avx2.cppmorph.avx2.cppsmooth.avx2.cppsumpixels.avx2.cppopencv_imgproc_AVX2.vcxproj -> C:\Users\liqian\AppData\Local\Temp\pip-install-6jpavinn\opencv-python_4bf9b16580254d7190cb574ec2fc8790\_skbuild\win-amd64-3.6\cmake-build\modules\imgproc\opencv_imgproc_AVX2.dir\Release\opencv_imgproc_AVX2.libC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(517,5): warning MSB8029: 中间目录或输出目录无法驻留在临时目录下,因为这可能会导致增量生成出现问题。 [C:\Users\liqian\AppData\Local\Temp\pip-install-6jpavinn\opencv-python_4bf9b16580254d7190cb574ec2fc8790\_skbuild\win-amd64-3.6\cmake-build\modules\imgproc\opencv_imgproc_AVX512_SKX.vcxproj]Building Custom Rule C:/Users/liqian/AppData/Local/Temp/pip-install-6jpavinn/opencv-python_4bf9b16580254d7190cb574ec2fc8790/opencv/modules/imgproc/CMakeLists.txtsumpixels.avx512_skx.cppopencv_imgproc_AVX512_SKX.vcxproj -> C:\Users\liqian\AppData\Local\Temp\pip-install-6jpavinn\opencv-python_4bf9b16580254d7190cb574ec2fc8790\_skbuild\win-amd64-3.6\cmake-build\modules\imgproc\opencv_imgproc_AVX512_SKX.dir\Release\opencv_imgproc_AVX512_SKX.libC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(517,5): warning MSB8029: 中间目录或输出目录无法驻留在临时目录下,因为这可能会导致增量生成出现问题。 [C:\Users\liqian\AppData\Local\Temp\pip-install-6jpavinn\opencv-python_4bf9b16580254d7190cb574ec2fc8790\_skbuild\win-amd64-3.6\cmake-build\modules\imgproc\opencv_imgproc_SSE4_1.vcxproj]Building Custom Rule C:/Users/liqian/AppData/Local/Temp/pip-install-6jpavinn/opencv-python_4bf9b16580254d7190cb574ec2fc8790/opencv/modules/imgproc/CMakeLists.txtimgwarp.sse4_1.cppresize.sse4_1.cppaccum.sse4_1.cppbox_filter.sse4_1.cppfilter.sse4_1.cppcolor_hsv.sse4_1.cppcolor_rgb.sse4_1.cppcolor_yuv.sse4_1.cppmedian_blur.sse4_1.cppmorph.sse4_1.cppsmooth.sse4_1.cppopencv_imgproc_SSE4_1.vcxproj -> C:\Users\liqian\AppData\Local\Temp\pip-install-6jpavinn\opencv-python_4bf9b16580254d7190cb574ec2fc8790\_skbuild\win-amd64-3.6\cmake-build\modules\imgproc\opencv_imgproc_SSE4_1.dir\Release\opencv_imgproc_SSE4_1.libC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(517,5): warning MSB8029: 中间目录或输出目录无法驻留在临时目录下,因为这可能会导致增量生成出现问题。 [C:\Users\liqian\AppData\Local\Temp\pip-install-6jpavinn\opencv-python_4bf9b16580254d7190cb574ec2fc8790\_skbuild\win-amd64-3.6\cmake-build\modules\python_bindings_generator\gen_opencv_python_source.vcxproj]C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(382,5): error MSB3491: 未能向文件“x64\Release\gen_opencv_python_source\gen_open.7733C44B.tlog\gen_opencv_python_source.lastbuildstate”写入命令行。路径: x64\Release\gen_opencv_python_source\gen_open.7733C44B.tlog\gen_opencv_python_source.lastbuildstate 超过 OS 最大路径限制。完全限定的文件名必须少于 260 个字符。 [C:\Users\liqian\AppData\Local\Temp\pip-install-6jpavinn\opencv-python_4bf9b16580254d7190cb574ec2fc8790\_skbuild\win-amd64-3.6\cmake-build\modules\python_bindings_generator\gen_opencv_python_source.vcxproj]C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(517,5): warning MSB8029: 中间目录或输出目录无法驻留在临时目录下,因为这可能会导致增量生成出现问题。 [C:\Users\liqian\AppData\Local\Temp\pip-install-6jpavinn\opencv-python_4bf9b16580254d7190cb574ec2fc8790\_skbuild\win-amd64-3.6\cmake-build\modules\.firstpass\videoio\opencv_videoio_plugins.vcxproj]C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(382,5): error MSB3491: 未能向文件“x64\Release\opencv_videoio_plugins\opencv_v.B9CC6B5E.tlog\opencv_videoio_plugins.lastbuildstate”写入命令行。路径: x64\Release\opencv_videoio_plugins\opencv_v.B9CC6B5E.tlog\opencv_videoio_plugins.lastbuildstate 超过 OS 最大路径限制。完全限定的文件名必须少于 260 个字符。 [C:\Users\liqian\AppData\Local\Temp\pip-install-6jpavinn\opencv-python_4bf9b16580254d7190cb574ec2fc8790\_skbuild\win-amd64-3.6\cmake-build\modules\.firstpass\videoio\opencv_videoio_plugins.vcxproj]Traceback (most recent call last):File "C:\Users\liqian\AppData\Local\Temp\pip-build-env-onh0v2r3\overlay\Lib\site-packages\skbuild\setuptools_wrap.py", line 642, in setupcmkr.make(make_args, install_target=cmake_install_target, env=env)File "C:\Users\liqian\AppData\Local\Temp\pip-build-env-onh0v2r3\overlay\Lib\site-packages\skbuild\cmaker.py", line 679, in makeself.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)File "C:\Users\liqian\AppData\Local\Temp\pip-build-env-onh0v2r3\overlay\Lib\site-packages\skbuild\cmaker.py", line 711, in make_impl"An error occurred while building with CMake.\n"An error occurred while building with CMake.Command:'C:\Users\liqian\AppData\Local\Temp\pip-build-env-onh0v2r3\overlay\Lib\site-packages\cmake\data\bin/cmake.exe' --build . --target install --config Release --Install target:installSource directory:C:\Users\liqian\AppData\Local\Temp\pip-install-6jpavinn\opencv-python_4bf9b16580254d7190cb574ec2fc8790Working directory:C:\Users\liqian\AppData\Local\Temp\pip-install-6jpavinn\opencv-python_4bf9b16580254d7190cb574ec2fc8790\_skbuild\win-amd64-3.6\cmake-buildPlease check the install target is valid and see CMake's output for more information.----------------------------------------ERROR: Failed building wheel 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
开始以为网络的问题,尝试了几次都没有成功。
第一种方案是使用 conda 命令安装成功了, conda install py-opencv
.
测试一下,安装成功。
查了半天资料,发现是python版本比较低,直接安装的话,高版本的opencv和低版本的python难以匹配。
因此,还有一种解决方案
安装较低版本的 opencv:
pip install opencv-python==3.4.9.31
包括 opencv-contrib-python :
pip install opencv-contrib-python==3.4.9.31
这样也是能够安装成功的。
参考链接:https://blog.csdn.net/z704630835/article/details/124564044
https://blog.csdn.net/u013548568/article/details/108885490
日常学习记录,一起交流讨论吧!侵权联系~
这篇关于python安装opencv出错 PEP 517的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!