因为我的python是用的 Anaconda 里自带的 python3.7
所以配置 opencv 需要在 Anaconda里面配置,Anaconda 的配置都在它安装目录的 Script 目录下,所以要把opencv配置在script目录下。
因为 opencv-python3.4.2 及以上版本的有些算法被申请专利了,所以尽量下3.4.2以下的版本。
但3.4.2以下的版本只有3.4.0.14,而且3.4.0.14只支持python3.6以下的版本,所以这里就不下3.4.0.14了,这里下载的是3.4.10.35的版本(目前用还没有问题)
首先给Anaconda换源,这样下载更快
如:在这 C:\Users\25097 这个目录下找 .condarc 文件,如果没有就cmd输入:
conda config --set show_channel_urls yes 这条命令,然后.condarc文件就出来了。
打开.condarc文件,将文件内容修改为:
channels:
- defaults
show_channel_urls: true
default_channels:
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
保存就可以了。
1. win+r 输入 cmd 进入命令窗口
我的Anaconda安装目录是(G:\StudyApp\Anaconda3-2018.12\Anaconda3-2018.12)
在命令窗口输入:
① G:
② cd StudyApp\Anaconda3-2018.12\Anaconda3-2018.12\Script
③ pip install opencv-python==3.4.10.35
④ pip install opencv-contrib-python==3.4.10.35 (安装opencv的拓展,如特征提取的算法等)
如果想查看已经安装的东西,就在命令窗口输入: pip liist
如果想卸载东西,就输入:pip uninstall xxx
注:要在Script目录下输入命令 (G:\StudyApp\Anaconda3-2018.12\Anaconda3-2018.12\Scripts>)
完成!