Conda 安装 OpenCV

1、conda 切换虚拟环境

activate 虚拟环境名称

温馨提示:查询虚拟环境列表

conda env list

 

2、conda 查看安装源

conda config --show-sources

我本地安装源为: Index of /anaconda/pkgs/free/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

修改conda 默认安装源,请执行如下指令:

# 安装清华安装源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

# 移除conda 默认安装源
conda config --remove channels defaults

3、conda 查询opencv 版本

conda search opencv

执行效果:

 

4、安装opencv 

温馨提示:安装opencv 注意python 版本最低要求和支持python 最高版本。

opencv3 安装:

(python310) C:\Windows\System32>conda install opencv=3.4.2
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
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=3.4.2 -> python[version='>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0']

Your python: python=3.10

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.

结论:安装OpenCV 3.4.2 不在 Python支持范围内。

 opencv4 安装:

(python310) C:\Windows\System32>conda install opencv=4.5.5
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: |
The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:

  - defaults/win-64::matplotlib==3.7.1=py310haa95532_1
done

## Package Plan ##

  environment location: D:\anaconda3\envs\python310

  added / updated specs:
    - opencv=4.5.5


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    eigen-3.3.7                |       h59b6b97_1         831 KB  defaults
    hdf5-1.8.15.1              |                2         1.4 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    libprotobuf-3.20.3         |       h23ce68f_0         2.2 MB  defaults
    numpy-1.21.5               |  py310h6d2d95c_3          25 KB  defaults
    numpy-base-1.21.5          |  py310h206c741_3         4.4 MB  defaults
    opencv-4.5.5               |  py310he826a15_4        24.5 MB  defaults
    ------------------------------------------------------------
                                           Total:        33.4 MB

The following NEW packages will be INSTALLED:

  eigen              pkgs/main/win-64::eigen-3.3.7-h59b6b97_1
  hdf5               anaconda/pkgs/free/win-64::hdf5-1.8.15.1-2
  libprotobuf        pkgs/main/win-64::libprotobuf-3.20.3-h23ce68f_0
  opencv             pkgs/main/win-64::opencv-4.5.5-py310he826a15_4
  pyqt               pkgs/main/win-64::pyqt-5.15.7-py310hd77b12b_0

The following packages will be DOWNGRADED:

  numpy                              1.23.5-py310h60c9a35_0 --> 1.21.5-py310h6d2d95c_3
  numpy-base                         1.23.5-py310h04254f7_0 --> 1.21.5-py310h206c741_3


Proceed ([y]/n)? y


Downloading and Extracting Packages

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

成功安装。 

5、验证opencv 是否安装成功

(python310) C:\Windows\System32>python
Python 3.10.10 | packaged by Anaconda, Inc. | (main, Mar 21 2023, 18:39:17) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> print(cv2.__version__)
4.5.5
>>>

opencv 环境初步搞定。

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值