我正在尝试在Mac上安装OpenCV-python,并且使用了以下内容:

$ pip安装opencv-python

这给了我以下错误:

$pip install opencv-python
Collecting opencv-python
  Using cached opencv_python-3.4.0.12-cp27-cp27m macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Collecting numpy>=1.11.1 (from opencv-python)
  Using cached numpy-1.14.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
Installing collected packages: numpy, opencv-python
  Found existing installation: numpy 1.8.0rc1
Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

然后我确实尝试了pip install --upgrade matplotlib,它没有改变任何东西。它只是告诉我:
matplotlib 2.2.2 requires backports.functools-lru-cache, which is not installed.
matplotlib 2.2.2 has requirement numpy>=1.7.1, but you'll have numpy 1.8.0rc1 which is incompatible.

当我发现有很多方法可以在互联网上安装openCV-python时,例如:
https://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/

并且我在其他Mac上安装了代码,但是在代码中出现了很多导入cv2问题。
如果有人有很好的解决方案或推荐来安装openCV-python,我将非常高兴。

谢谢

最佳答案

总而言之,macOS预先安装了Python,因此您不应该对已安装的软件包感到困惑,因为某些系统实用程序依赖于它们。

https://docs.python.org/3.7/using/mac.html



您应该看看venvvirtualenv

您可以阅读以下答案:https://stackoverflow.com/a/41972262/4796844,它将使您掌握基础知识。

简而言之,要解决您的问题:

$ python3 -m venv ./project-name
$ . ./project-name/bin/activate
$ pip install opencv-python

离开虚拟环境,只需:
$ deactivate

关于python - 如何安装没有导入cv2错误的openCV_python?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49662022/

10-11 19:12
查看更多