【已解决】安装cv2时Building wheel for opencv-python终端卡死

这篇具有很好参考价值的文章主要介绍了【已解决】安装cv2时Building wheel for opencv-python终端卡死。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1 问题背景

环境:

  • Ubuntu20.04
  • Python3.6

现象:终端输出类似下面的命令,并卡住不动

Building wheel for opencv-python (PEP 517) ... 

building wheel for opencv-python (pep 517),告别Bug,opencv,python,计算机视觉,人工智能

2 问题探索

首先,OpenCV较旧的Python版本不需要进行滚轮编译,因此造成编译在

Building wheel for opencv-python (PEP 517)

处停止。为了防止因为pip版本较旧引起干扰,首先运行

pip install --upgrade pip

更新pip版本,接着再次安装

pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple

接着大概率能解决Building wheel for opencv-python (PEP 517),但是遇到新的现象,终端运行到下面指令时卡住

building wheel for opencv(pyproject.toml)  ...

我们希望看看后端到底是什么情况,用--verbose运行安装命令跟踪安装过程,也可以检查安装的百分比

[ 48%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/fast_convolution/fast_convolution.avx2.cpp.o
[ 48%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/layers/layers_common.avx2.cpp.o
[ 48%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/int8layers/layers_common.avx2.cpp.o
[ 48%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/layers/layers_common.avx512_skx.cpp.o
[ 48%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/int8layers/layers_common.avx512_skx.cpp.o
[ 48%] Linking CXX static library ../../lib/libopencv_dnn.a
[ 48%] Built target opencv_dnn
[ 48%] Processing OpenCL kernels (features2d)
[ 49%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/affine_feature.cpp.o
[ 49%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/agast.cpp.o
[ 49%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/agast_score.cpp.o
[ 49%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/akaze.cpp.o
[ 49%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/bagofwords.cpp.o
[ 49%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/blobdetector.cpp.o
[ 49%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/brisk.cpp.o
[ 49%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/draw.cpp.o
[ 49%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/dynamic.cpp.o
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/evaluation.cpp.o
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/fast.cpp.o
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/fast_score.cpp.o
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/feature2d.cpp.o
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/gftt.cpp.o

发现后端确实一直在运行,由于OpenCV体积较大,编译时间较长,导致不显示安装进度的化,前端出现假死现象,静静等待即可。

3 问题解决

更新pip版本

pip install --upgrade pip

显示安装进程

pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple --verbose

等待安装完成

building wheel for opencv-python (pep 517),告别Bug,opencv,python,计算机视觉,人工智能

文章最后,推荐一个研究深度学习都会碰到的bug解析
【已解决】探究CUDA out of memory背后原因,如何释放GPU显存?

4 告别Bug

本文收录于《告别Bug》专栏,该专栏记录人工智能领域中各类Bug以备复查,文章形式为:问题背景 + 问题探索 + 问题解决,订阅专栏+关注博主后可通过下方名片联系我进入AI技术交流群帮忙解决问题


🔥 更多精彩专栏文章来源地址https://www.toymoban.com/news/detail-778915.html

  • 《ROS从入门到精通》
  • 《Pytorch深度学习实战》
  • 《机器学习强基计划》
  • 《运动规划实战精讲》

👇源码获取 · 技术交流 · 抱团学习 · 咨询分享 请联系👇

到了这里,关于【已解决】安装cv2时Building wheel for opencv-python终端卡死的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包