opencv-python的安装——问题篇
- (一)、问题
- 1、问题:“Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly”
- 2、问题:“ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。”
- 3、问题:“WARNING: The script wheel.exe is installed in 'C:\Users\XXX\AppData\Roaming\Python\Python36\Scripts' which is not on PATH.”
- (二)、离线安装
- (三)、选择确定版本号后安装
(一)、问题
通过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”,我还没来得及试一下,就通过第三种方法安装好了
(三)、选择确定版本号后安装
依次输入:
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/
以下是安装好的样子: