ubuntu18 anaconda的虚拟环境下安装python版opencv

怎么创建虚拟环境见创建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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值