我正在尝试在我的Mac上安装OpenCV-python,我使用了以下内容:
$ pip install 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,我将非常高兴。
由于
答案 0 :(得分:1)
总之,macOS预装了Python,你不应该搞乱安装的软件包,因为一些系统实用程序依赖它们。
https://docs.python.org/3.7/using/mac.html
Apple提供的Python版本分别安装在/System/Library/Frameworks/Python.framework和/ usr / bin / python中。您永远不应修改或删除这些内容,因为它们由Apple控制并由Apple或第三方软件使用。请记住,如果您选择从python.org安装较新的Python版本,您的计算机上将安装两个不同但功能齐全的Python,因此您的路径和用法与您想要的一致非常重要。
您应该查看venv或virtualenv。
您可以阅读以下答案:https://stackoverflow.com/a/41972262/4796844,它将帮助您了解基础知识。
简而言之,要解决您的问题:
$ python3 -m venv ./project-name
$ . ./project-name/bin/activate
$ pip install opencv-python
离开虚拟环境,只需:
$ deactivate