怎么创建虚拟环境见创建env虚拟环境
进入虚拟环境后conda install opencv
,按照提示安装完后,打开终端打开sypder,运行读取图片的程序
import cv2
img = cv2.imread("1.png")#修改为你自己的路径
cv2.namedWindow("Image")
cv2.imshow("Image",img)
cv2.waitKey(0)
cv2.destroyAllWindows()
然后运行报错
The function is not implemented. Rebuilt the library with Windows, GTK+2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvSowImage
安装不完整,看了很多博客说conda安装opencv-python或则带有contribute的包都提示CondaHTTPError的错误
需要更换镜像源
pip install opencv-contrib-python==3.4.1.15 -i https://pypi.tuna.tsinghua.edu.cn/simple
参数i:临时使用,添加“-i”或“–index”参数
最后运行图片成功
类似conda也有修改镜像源
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
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --set show_channel_urls yes
参考:
https://www.cnblogs.com/feixiablog/p/8320602.html
https://blog.csdn.net/u010821666/article/details/89917618