首先进入opencv-python官网-opencv-python
上面左边是菜单栏,也可以选Release history查看旧版的opencv-python,同时注意菜单栏下方Meta栏会有python版本限制条件,同时Project description会有一些构建工程需要注意的地方,比如pip包的版本等等,还有其他内容请自行查看。
复制如下到pycharm终端运行即可(确保pip的版本满足说明的最低19.3版本要求)
pip install opencv-python==4.5.1.48
如果因为其他原因无法通过上面方式安装,可以尝试更换下载源,这里贴出清华源:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
pip install --index-url https://pypi.douban.com/simple tensorflow
pip install --index-url http://mirrors.aliyun.com/pypi/simple/ tensorflow
#上面两行是下载tensorflow的改成pytoch也可
实在不行,那就在官网处下载离线的opencv-python 4.5.1.48包,把这个包放到对应虚拟环境下的script文件夹,然后再终端进入这个目录执行如下代码
pip install 这里输入你下载的安装包的全称,包括后缀
配置完成
顺便贴一下opencv-python的使用指南网站:
opencv-python tutorial