当前位置:   article > 正文

Conda 安装 OpenCV_conda安装opencv

conda安装opencv

1、conda 切换虚拟环境

activate 虚拟环境名称

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

conda env list

 

2、conda 查看安装源

conda config --show-sources

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

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

  1. # 安装清华安装源
  2. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  3. # 移除conda 默认安装源
  4. conda config --remove channels defaults

3、conda 查询opencv 版本

conda search opencv

执行效果:

 

4、安装opencv 

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

opencv3 安装:

  1. (python310) C:\Windows\System32>conda install opencv=3.4.2
  2. Collecting package metadata (current_repodata.json): done
  3. Solving environment: failed with initial frozen solve. Retrying with flexible solve.
  4. Collecting package metadata (repodata.json): done
  5. Solving environment: failed with initial frozen solve. Retrying with flexible solve.
  6. Solving environment: -
  7. Found conflicts! Looking for incompatible packages.
  8. This can take several minutes. Press CTRL-C to abort.
  9. failed
  10. UnsatisfiableError: The following specifications were found
  11. to be incompatible with the existing python installation in your environment:
  12. Specifications:
  13. - opencv=3.4.2 -> python[version='>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0']
  14. Your python: python=3.10
  15. If python is on the left-most side of the chain, that's the version you've asked for.
  16. When python appears to the right, that indicates that the thing on the left is somehow
  17. not available for the python version you are constrained to. Note that conda will not
  18. change your python version to a different minor version unless you explicitly specify
  19. that.

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

 opencv4 安装:

  1. (python310) C:\Windows\System32>conda install opencv=4.5.5
  2. Collecting package metadata (current_repodata.json): done
  3. Solving environment: failed with initial frozen solve. Retrying with flexible solve.
  4. Collecting package metadata (repodata.json): done
  5. Solving environment: |
  6. The environment is inconsistent, please check the package plan carefully
  7. The following packages are causing the inconsistency:
  8. - defaults/win-64::matplotlib==3.7.1=py310haa95532_1
  9. done
  10. ## Package Plan ##
  11. environment location: D:\anaconda3\envs\python310
  12. added / updated specs:
  13. - opencv=4.5.5
  14. The following packages will be downloaded:
  15. package | build
  16. ---------------------------|-----------------
  17. eigen-3.3.7 | h59b6b97_1 831 KB defaults
  18. hdf5-1.8.15.1 | 2 1.4 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  19. libprotobuf-3.20.3 | h23ce68f_0 2.2 MB defaults
  20. numpy-1.21.5 | py310h6d2d95c_3 25 KB defaults
  21. numpy-base-1.21.5 | py310h206c741_3 4.4 MB defaults
  22. opencv-4.5.5 | py310he826a15_4 24.5 MB defaults
  23. ------------------------------------------------------------
  24. Total: 33.4 MB
  25. The following NEW packages will be INSTALLED:
  26. eigen pkgs/main/win-64::eigen-3.3.7-h59b6b97_1
  27. hdf5 anaconda/pkgs/free/win-64::hdf5-1.8.15.1-2
  28. libprotobuf pkgs/main/win-64::libprotobuf-3.20.3-h23ce68f_0
  29. opencv pkgs/main/win-64::opencv-4.5.5-py310he826a15_4
  30. pyqt pkgs/main/win-64::pyqt-5.15.7-py310hd77b12b_0
  31. The following packages will be DOWNGRADED:
  32. numpy 1.23.5-py310h60c9a35_0 --> 1.21.5-py310h6d2d95c_3
  33. numpy-base 1.23.5-py310h04254f7_0 --> 1.21.5-py310h206c741_3
  34. Proceed ([y]/n)? y
  35. Downloading and Extracting Packages
  36. Preparing transaction: done
  37. Verifying transaction: done
  38. Executing transaction: done

成功安装。 

5、验证opencv 是否安装成功

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

opencv 环境初步搞定。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/631736
推荐阅读
相关标签
  

闽ICP备14008679号