opencv-python的安装——问题篇

(一)、问题

  通过anaconda prompt安装opencv-python

pip install opencv-python -i http://mirrors.ustc.edu.cn/simple

1、问题:“Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly”

在这里插入图片描述
报错原因:

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

解决办法参考:
①安装opencv时报错:Could not build wheels for opencv-python which use PEP 517 and cannot be installed direc
②Package | 解决 Could not build wheels for opencv-python which use PEP 517 and cannot be installed

我选择的办法是升级pip工具包:
在这里插入图片描述

2、问题:“ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。”

在上一步之后这里仍旧报错,原因如下,没有用户权限,需要在命令后添加“–user”

ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。: 'C:\\Users\\Arata\\AppData\\Local\\Temp\\pip-uninstall-4med2gjw\\pip.exe'
Consider using the `--user` option or check the permissions.

3、问题:“WARNING: The script wheel.exe is installed in ‘C:\Users\XXX\AppData\Roaming\Python\Python36\Scripts’ which is not on PATH.”

经过上一步已经有有权限下载,但是仍旧报错
在这里插入图片描述
报错原因(缺少环境变量):

 WARNING: The script wheel.exe is installed in 'C:\Users\XXX\AppData\Roaming\Python\Python36\Scripts' which is not on PATH.
 Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

解决办法(新建一个环境变量):
  我采用的实在系统变量中新建一个,然后将刚开报错的路径加进去,然后重新执行一次下面命令就成功了,如果不行,请重开一个窗口,或者尝试下面链接的办法。

pip install --upgrade pip setuptools wheel -i http://pypi.douban.com/simple/ --user --trusted-host pypi.douban.com

截图演示:
在这里插入图片描述
在这里插入图片描述

(二)、离线安装

  使用pip语句后安装依旧失败,使用conda安装出现以下提示,那我们进入官网去下载对应版本的离线包,再使用和day1安装torch一样的办法安装,地址“https://anaconda.org”,我还没来得及试一下,就通过第三种方法安装好了
在这里插入图片描述

关于Python中使用pip安装库是出现的一个问题

(三)、选择确定版本号后安装

依次输入:

pip install opencv-python==3.4.1.15 -i http://mirrors.aliyun.com/pypi/simple/
pip install opencv-contrib-python==3.4.1.15 -i http://mirrors.aliyun.com/pypi/simple/

以下是安装好的样子:
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值