博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MAC 安装opencv的过程
阅读量:3903 次
发布时间:2019-05-23

本文共 1975 字,大约阅读时间需要 6 分钟。

代码里cv2标红了,发现需要安装opencv,于是开始了。。。。

一开始查到说安装cv2模块,不能直接用命令pip install cv2安装,要用命令如下:

pip install opencv-python

使用命令后报错如下:

ERROR: Exception:

Traceback (most recent call last):
File “/Users/xxx/opt/anaconda3/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py”, line 171, in _merge_into_criterion
crit = self.state.criteria[name]
KeyError: ‘opencv-python’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/Users/xxx/opt/anaconda3/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py”, line 438, in _error_catcher

发现是网速太慢,换了镜像网址,命令如下:

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

更换镜像网址后出现最致命的错误:

ERROR: Could not find a version that satisfies the requirement opencv-python

ERROR: No matching distribution found for opencv-python

后来发现是opencv没有osx系统对应的包

解决办法:使用anaconda集成

集成发现anaconde的镜像网址全部被墙了(没有)

解决办法:安装homebrew

安装好了,开始安装opencv

使用命令:

brew install opencv

报错:

curl: (22) The requested URL returned error: 404 Not Found

Error: Failed to download resource “eigen”

但同时终端回显示下载失败文件的下载网址:

Download failed: https://storage.googleapis.com/dart-archive/channels/stable/release/2.7.2/sdk/dartsdk-macos-x64-release.zip

之后我们就可以用自己浏览器或者下载器下载需要的文件。

之后使用终端查看Homebrew的缓存地址:

brew --cache

打印出以下地址:

/Users//Library/Caches/Homebrew

最后将下载下来的文件拷贝到缓存地址:

cp ~/Downloads/dartsdk-macos-x64-release.zip /Users/xxx/Library/Caches/Homebrew

最后使用Homebrew安装,这个时候就可以成功了。

但是问题来了,我的文件网址url"https://github.com/opencv/opencv/archive/4.5.2.tar.gz"

网址打不开,此方法行不通。。。。

之后发现,在bilibli看到一遍文章,网址如下,https://www.bilibili.com/read/cv9542204

anaconda绝了!
步骤:
1.
打开Anaconda,点击步骤:Environment > Create > Python3.x > 输入name > Create
2.
勾选All,点击Update Index…。搜索出opencv并勾选。Apply。
3.在name中的终端输入命令,没报错即可

python

import cv2

打开pycharm中的项目,点开preferences > project:xxx > python interpreter,点击其右锯齿,选择Add。左边选择Conda Environment,右边点击existing environment,然后再文件路径中选择对应的python文件,例如/Users/xxx/opt/anaconda3/envs/tensorflow/bin/python

然后代码里的cv2就不标红了,ok

转载地址:http://lnoen.baihongyu.com/

你可能感兴趣的文章
敲两遍引号键才出现
查看>>
latex subfigure
查看>>
latex /figure /label 序号 /ref /label 序号 不一致
查看>>
latex pageref 指明图片在某一页
查看>>
latex jpg转成eps
查看>>
Tripwire 配置 使用
查看>>
我问佛(仓央嘉措)
查看>>
win7 动态磁盘 无法安装fedora
查看>>
win7 动态硬盘
查看>>
Openoffice fedora/linux build
查看>>
openoffice development
查看>>
no office executable found! error still exist after adding /openoffice.org3/program to classpath
查看>>
Eclipse OpenOffice Development Plugin
查看>>
Netbeans 6.5 JDK was not found Unsupported Java VM
查看>>
Netbeans显示行号
查看>>
latex BibTex 引文顺序
查看>>
NetBeans 6.5 新建项目 project folder already exist and is not empty
查看>>
open office (ooffice) 如何使用公式编辑器 (formula)
查看>>
mysql 自动增长 字段 插入
查看>>
使用JDBC时 Class.forName()的作用
查看>>