使用 Conda 和 Spyder 安装 OpenCV

Installing OpenCV with Conda and Spyder

我在使用 Conda 安装 OpenCV 时遇到问题。我尝试了 运行 多个命令,其中 none 行得通。例如,当我 运行 conda install -c anaconda opencv (根据 https://anaconda.org/anaconda/opencv)时,我得到这个错误:

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.

为什么会这样,我如何在 Spyder 中安装 OpenCV?

谢谢。

Python 3.8 比较新。根据错误,conda 包管理器似乎仍然不支持 Python 3.8.

尝试使用此命令下载:

pip install opencv-python

有关正确的指南,请参阅 https://pypi.org/project/opencv-python/

这个问题的答案是将 Anaconda 更新到最新版本:

conda update -n base -c defaults conda

然后就可以正常安装opencv了:

conda install -c conda-forge opencv