当前位置: 首页 > news >正文

anaconda安装opencv -> python[version=‘>=2.7,<2.8.0a0|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0‘]

系统崩溃,机器重新装, 同样的配置和安装,突然报错,

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: - 
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed                                                                                                                         

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  - opencv -> python[version='>=2.7,<2.8.0a0|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0']

Your python: python=3.8

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

The following specifications were found to be incompatible with your system:

  - feature:/linux-64::__glibc==2.27=0
  - feature:|@/linux-64::__glibc==2.27=0
  - opencv -> libgcc-ng[version='>=7.2.0'] -> __glibc[version='>=2.17']

Your installed version is: 2.27

官方推荐的办法是

https://github.com/pytorch/vision/issues/3207

pip install opencv-contrib-python

发现如果用
conda install -c conda-forge opencv
会有一大堆不兼容。

顺便说一下,以前有说把python降到3.5版本的,我长时间用3.7和3.8,都没有问题,今天突然报错,反而很奇怪。又搜索了一下,网上有详细介绍兼容性安装的,内容如下,有时间大家可以自己去搜索对比一下,以避免冲突,

Anaconda 2020.11 issue with OpenCV

Recently I installed Anaconda 2020.11 on my Mac machine. When I tried to installed opencv package, it showed errors. Below is the error excrept:

$ conda install -c conda-forge opencv
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: -
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  - opencv -> python[version='>=2.7,<2.8.0a0|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0']

Your python: python=3.8

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

Above error suggested that opencv package in the current repository is only supported with python version <3.8.0a0. After googling for a bit, I found many different solution but none of them worked in my case. My conda details:

$ conda info
     active environment : pandas
    active env location : /Users/user-abc/anaconda3/envs/pandas
            shell level : 1
       user config file : /Users/user-abc/.condarc
 populated config files : /Users/user-abc/.condarc
          conda version : 4.9.2
    conda-build version : 3.20.5
         python version : 3.8.5.final.0
       virtual packages : __osx=10.15.7=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /Users/user-abc/anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/osx-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/osx-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /Users/user-abc/anaconda3/pkgs
                          /Users/user-abc/.conda/pkgs
       envs directories : /Users/user-abc/anaconda3/envs
                          /Users/user-abc/.conda/envs
               platform : osx-64
             user-agent : conda/4.9.2 requests/2.24.0 CPython/3.8.5 Darwin/19.6.0 OSX/10.15.7
                UID:GID : 502:20
             netrc file : None
           offline mode : False

So, I started searching for availble python versions of conda:

$ conda search python
Loading channels: done
# Name                       Version           Build  Channel
python                        2.7.13     h32f5f24_13  pkgs/main
python                        2.7.13     h89fad4f_16  pkgs/main
python                        2.7.13     hdada7c8_15  pkgs/main
...
python                         3.7.4      h359304d_1  pkgs/main
python                         3.7.5      h359304d_0  pkgs/main
python                         3.7.6      h359304d_2  pkgs/main
python                         3.7.7 hc70fcce_0_cpython  pkgs/main
python                         3.7.7      hf48f09d_4  pkgs/main
python                         3.7.7 hfe9666f_0_cpython  pkgs/main
python                         3.7.9      h26836e1_0  pkgs/main
python                         3.8.0      h359304d_0  pkgs/main
python                         3.8.0      h359304d_1  pkgs/main
python                         3.8.0      h359304d_2  pkgs/main
python                         3.8.1      h359304d_1  pkgs/main
python                         3.8.2      hc70fcce_0  pkgs/main
python                         3.8.2     hf48f09d_13  pkgs/main
python                         3.8.2      hfe9666f_0  pkgs/main
python                         3.8.3      h26836e1_1  pkgs/main
python                         3.8.3      h26836e1_2  pkgs/main
python                         3.8.5      h26836e1_0  pkgs/main
python                         3.8.5      h26836e1_1  pkgs/main
python                         3.9.0      h88f2d9e_1  pkgs/main
python                         3.9.0      h88f2d9e_2  pkgs/main
python                         3.9.1      h88f2d9e_2  pkgs/main

Then, searched for available opencv package.

$ conda search opencv
Loading channels: done
# Name                       Version           Build  Channel
opencv                         3.3.1  py27h2dac755_0  pkgs/main
opencv                         3.3.1  py27h4e978fd_0  pkgs/main
opencv                         3.3.1  py27h60a5f38_1  pkgs/main
...
opencv                         3.4.2  py36h40b0b35_1  pkgs/main
opencv                         3.4.2  py36h6fd60c2_0  pkgs/main
opencv                         3.4.2  py36h6fd60c2_1  pkgs/main
opencv                         3.4.2  py37h40b0b35_0  pkgs/main
opencv                         3.4.2  py37h40b0b35_1  pkgs/main
opencv                         3.4.2  py37h6fd60c2_0  pkgs/main
opencv                         3.4.2  py37h6fd60c2_1  pkgs/main

Look at the last row. Check py37h6fd60c2_1

opencv                         3.4.2  py37h6fd60c2_1  pkgs/main

This confirmed that the latest opencv package is built with py37 packages and hence it is not installable with python3.8.

Now the most tempting thing to do is to downgrade python version.

$ conda install python=3.7

Wait, this is going to take lot of time and in last will show multiple conflicts which is not easy to resolve.

So, what is the simple solution ? Virtual environment comes to rescue. By default, anaconda runs in environment name “base”. If you are familiar with python, we have package called virtualenv to create virtual environment. The same thing we can do here with conda.

Steps:

conda create -n myenv python=3.7	# This will create a virtual environment named myenv with python3.7
conda activate myenv
conda install -c conda-forge opencv

另外的参考内容,

python - Installing OpenCV with Conda and Spyder - Stack Overflow

conda update -n base -c defaults conda
conda install -c conda-forge opencv

相关文章:

  • VIM的一些常指令和用法
  • 如何自定义FileZilla编辑文件的默认打开方式
  • 如何在 Ubuntu 和其它 Linux 发行版中更改时区
  • OpenVINO: export failure: libpython3.9.so.1.0: cannot open shared object file: No such file or direc
  • udev规则以及编写
  • ROS + UDEV管理开源小车rikirobot的USB设备
  • (ros//EnvironmentVariables)ros环境变量
  • ROS移植机器人小车:小车主机与从机电脑的通信
  • Linux查看版本和系统信息
  • ROS移植机器人小车: rikirobot试运行
  • Linux+Grub启动引导修复错误:Gnu Grub Version 2.04 Minimal BASH-like editing is supported...
  • Ubuntu下安装指定版本的cmake包
  • Ubuntu20.04编译安装Opencv4.5.5安装包报错:Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
  • Ubuntu20.04编译安装Opencv4.5.5
  • Linux如何查看内核版本并安装内核头文件linux-headers-generic
  • [ JavaScript ] 数据结构与算法 —— 链表
  • 2017前端实习生面试总结
  • Angular6错误 Service: No provider for Renderer2
  • avalon2.2的VM生成过程
  • flutter的key在widget list的作用以及必要性
  • Laravel核心解读--Facades
  • learning koa2.x
  • mysql外键的使用
  • swift基础之_对象 实例方法 对象方法。
  • Three.js 再探 - 写一个跳一跳极简版游戏
  • 海量大数据大屏分析展示一步到位:DataWorks数据服务+MaxCompute Lightning对接DataV最佳实践...
  • 双管齐下,VMware的容器新战略
  • 微信小程序填坑清单
  • 仓管云——企业云erp功能有哪些?
  • ​sqlite3 --- SQLite 数据库 DB-API 2.0 接口模块​
  • (day 2)JavaScript学习笔记(基础之变量、常量和注释)
  • (Forward) Music Player: From UI Proposal to Code
  • (保姆级教程)Mysql中索引、触发器、存储过程、存储函数的概念、作用,以及如何使用索引、存储过程,代码操作演示
  • (超详细)语音信号处理之特征提取
  • (二)c52学习之旅-简单了解单片机
  • (附源码)计算机毕业设计SSM基于健身房管理系统
  • (四)c52学习之旅-流水LED灯
  • (一)基于IDEA的JAVA基础12
  • (转)mysql使用Navicat 导出和导入数据库
  • (转载)OpenStack Hacker养成指南
  • ****Linux下Mysql的安装和配置
  • ***通过什么方式***网吧
  • ***原理与防范
  • *_zh_CN.properties 国际化资源文件 struts 防乱码等
  • .apk 成为历史!
  • /etc/fstab和/etc/mtab的区别
  • @test注解_Spring 自定义注解你了解过吗?
  • [Angularjs]asp.net mvc+angularjs+web api单页应用
  • [AutoSar]BSW_Com02 PDU详解
  • [C++基础]-初识模板
  • [CSS3备忘] transform animation 等
  • [IE9] GPU硬件加速到底是实用创新还是噱头
  • [java]删除数组中的某一个元素
  • [JavaWeb]—前端篇
  • [LeetCode] 596:超过5名学生的课