Mac anaconda OpenCV环境配置
来源:互联网 发布:socket网络通信 编辑:程序博客网 时间:2024/06/07 09:23
Mac anaconda|Miniconda OpenCV环境配置
Mac本来就是小众系统,专门拿Mac来码代码就更少了。这就造成了网上对一些环境的配置的教程很少。然后开源的库配置起来简直就是坑啊,巨坑。不说了,说多了都是泪。只是希望本篇文章能给Mac“玩家”带来一些方便。
总的环境
- 系统版本:macOS Sierra 10.12.6
- Python版本 :Python 2.7.13
- conda版本:conda 4.3.22
- 选择的OpenCV版本:opencv 3.1.0(这很重要,我就是因为选择了opencv2.4,还有opencv3.2的版本始终依赖缺失)
1.选择一个国内的镜像
原因:河蟹神兽实在太厉害了,选择conda的默认镜像网站下载,不仅仅是慢的问题,而且经常出现断流,直接报错中断下载了。
假如你出现了conda、 http、 error等单词在终端的报错内容里出现,请换一个镜像网站。推荐:清华大学开源软件镜像站
清华大学的镜像站不止有anaconda的库,还有常见的Ubuntu之类的,实在太好用了。安利一波~~~~
不知道为什么,清华维护的Conda 三方源反而下载opencv的速度更快。
推荐使用一下代码添加镜像网站:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
2.测试一下镜像速度
- 运行
conda install numpy
以下是测试结果:
zhangdeMacBook-Air:~ zhang$ conda install numpyFetching package metadata .......Solving package specifications: .Package plan for installation in environment /Users/zhang/miniconda2:The following NEW packages will be INSTALLED: mkl: 2017.0.3-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free numpy: 1.13.1-py27_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/freeThe following packages will be UPDATED: conda: 4.3.21-py27_0 defaults --> 4.3.22-py27_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/freeThe following packages will be SUPERSEDED by a higher-priority channel: conda-env: 2.6.0-0 defaults --> 2.6.0-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/freeProceed ([y]/n)? yconda-env-2.6. 100% |################################| Time: 0:00:00 62.22 kB/smkl-2017.0.3-0 100% |################################| Time: 0:01:10 1.65 MB/snumpy-1.13.1-p 100% |################################| Time: 0:00:01 2.73 MB/sconda-4.3.22-p 100% |################################| Time: 0:00:00 2.71 MB/szhangdeMacBook-Air:~ zhang$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/zhangdeMacBook-Air:~ zhang$ conda install pandasFetching package metadata .......Solving package specifications: .Package plan for installation in environment /Users/zhang/miniconda2:The following NEW packages will be INSTALLED: pandas: 0.20.3-py27_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge python-dateutil: 2.6.1-py27_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge pytz: 2017.2-py27_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forgeThe following packages will be SUPERSEDED by a higher-priority channel: conda: 4.3.22-py27_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free --> 4.3.22-py27_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge conda-env: 2.6.0-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free --> 2.6.0-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forgeProceed ([y]/n)? yconda-env-2.6. 100% |################################| Time: 0:00:00 110.49 kB/spytz-2017.2-py 100% |################################| Time: 0:00:00 1.83 MB/spython-dateuti 100% |################################| Time: 0:00:00 2.12 MB/spandas-0.20.3- 100% |################################| Time: 0:00:04 2.41 MB/sconda-4.3.22-p 100% |################################| Time: 0:00:00 2.26 MB/s
3. conda安装opencv
- 尝试使用
conda install opencv
安装
默认安装的是opencv 3.2.0
结果:安装成功了???? - 进入Python界面看看
- 使用ipython, 进入增强版Python交互界面
- 使用
import cv2
导入 opencv的模块 - 显然失败了
我也试图用其他工具例如homebrew安装,无一例外都失败了。也许3.2.0有什么bug吧。
zhangdeMacBook-Air:~ zhang$ ipythonPython 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:05:08) Type "copyright", "credits" or "license" for more information.IPython 5.4.1 -- An enhanced Interactive Python.? -> Introduction and overview of IPython's features.%quickref -> Quick reference.help -> Python's own help system.object? -> Details about 'object', use 'object??' for extra details.In [1]: import cv2---------------------------------------------------------------------------ImportError Traceback (most recent call last)<ipython-input-1-72fbbcfe2587> in <module>()----> 1 import cv2ImportError: dlopen(/Users/zhang/miniconda2/lib/python2.7/site-packages/cv2.so, 2): Library not loaded: @rpath/libopenblasp-r0.2.19.dylib Referenced from: /Users/zhang/miniconda2/lib/libopencv_hdf.3.2.0.dylib Reason: image not found
3.使用 conda install opencv=3.1.0
安装
看看结果:
zhangdeMacBook-Air:~ zhang$ conda install opencv=3.1.0Fetching package metadata .......Solving package specifications: .Package plan for installation in environment /Users/zhang/miniconda2:The following packages will be DOWNGRADED: opencv: 3.2.0-np112py27_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge --> 3.1.0-np112py27_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forgeProceed ([y]/n)? yopencv-3.1.0-n 100% |################################| Time: 0:00:15 2.51 MB/s
- 显然又一次成功安装了,再来看看Python能否导入
zhangdeMacBook-Air:~ zhang$ ipythonPython 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:05:08) Type "copyright", "credits" or "license" for more information.IPython 5.4.1 -- An enhanced Interactive Python.? -> Introduction and overview of IPython's features.%quickref -> Quick reference.help -> Python's own help system.object? -> Details about 'object', use 'object??' for extra details.In [1]: import cv2In [2]: exit
- 命令
import cv2
导入opencv成功
4.总结一下
命令如下:
#为了加快下载速度使用清华的镜像conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/#最新版3.2.0有毒啊,只能3.1.0conda install opencv=3.1.0
阅读全文
0 0
- Mac anaconda OpenCV环境配置
- anaconda opencv环境配置
- Python环境mac+anaconda
- Anaconda配置opencv
- 安装anaconda + opencv for mac
- anaconda多环境配置
- Anaconda环境配置
- Anaconda环境基本配置
- 使用Anaconda配置环境
- Mac 环境下配置opencv(Eclipse)
- Mac 环境下下配置opencv +python
- Mac Xcode 配置OpenCv开发环境
- 《Machine learning for OpenCV》 Windows下的Anaconda+OpenCV的环境配置
- 【Windows】PyCharm+Anaconda+OpenCV配置
- 国内使用Mac Anaconda安装opencv
- 在mac上配置LightGBM以及不同python版本在anaconda下环境配置
- tensorflow01 win10 anaconda 环境配置
- win10 anaconda tensorflow环境配置
- linq比较日期的方式
- 静态成员和静态成员函数
- eclipse打开properties配置文件中文显示字符的编码
- RocketMQ实战(二)
- LeetCode(17)--Letter Combinations of a Phone Number
- Mac anaconda OpenCV环境配置
- C++继承
- hdu1350
- 点击后换按钮图片
- [LeetCode] 526. Beautiful Arrangement
- (DP,多重背包) Ahui Writes Word -- HDOJ
- 快速幂&&codeforce 678D
- Ambari部署HDP2.3
- Morley's Theorem UVA