python - 使用 Homebrew 安装 openCV 时遇到问题

标签 python opencv homebrew

我正在运行 mac os x mavericks,我正在尝试使用 Homebrew 安装 openCV 我不确定如何修复它,我应该卸载 Homebrew 和 python,然后再试一次,如果可以,我该如何卸载它们

首先我做了这个 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install )" 然后这个 brew tap homebrew/science 这是有效的,因为当我再次输入 brew tap homebrew/science 时,我收到了警告:已点击!

但是当我输入 brew info opencv 时,我收到了这个错误 错误:opencv 没有可用的公式 当我尝试 brew install opencv 它显示了这个

Searching formulae...
Searching taps...
mymac:~ user$

这是我运行 brew doctor 时得到的结果

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: Python is installed at /Library/Frameworks/Python.framework

Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.

Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:

    2to3
    2to3-2.7
    idle
    idle2.7
    pydoc
    pydoc2.7
    python
    python-config
    python2.7
    python2.7-config
    pythonw
    pythonw2.7
    smtpd.py
    smtpd2.7.py

Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
    echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile

Warning: Your Xcode (6.0.1) is outdated
Please update to Xcode 6.1.
Xcode can be updated from the App Store.

更新 1

我解决了我的问题 我决定发布它以防万一有人遇到同样的问题 这是我做的

untap homebrew/science
brew update
brew doctor 
brew tap homebrew/science

最佳答案

这是我在 linux 上安装的过程。它在过去对我来说很有效:

  1. http://opencv.org/downloads.html 下载 OpenCV 2.4.9适用于 Linux/Mac OS 和提取。

  2. 在终端中,导航到新提取的目录,并在终端中使用 mkdir build 创建一个名为 build 的新目录。然后cdbuild

  3. 现在,在终端中输入:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D BUILD_JPEG=ON ..

  1. 完成后,在终端中输入 make -j 4 这可能需要一段时间。

  2. 现在在终端输入sudo make install

  3. 然后 sudo sh -c 'echo "/usr/local/lib">/etc/ld.so.conf.d/opencv.conf' sudo ldconfig

  4. 如果成功,您应该能够在 python 提示符下import cv2 而不会出现任何错误。

关于python - 使用 Homebrew 安装 openCV 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26981728/

相关文章:

python - 如何用连字符或下划线替换具有路径参数的 URL 中的空格

java - 提高android + opencv项目中的帧速率

python - 使用 OpenCV Python 查找字母并将其着色为红色

python-3.x - 尝试使用 brew 安装 Python3

macos - 将本地配方注入(inject)到brew中

python - 如何替换参数给定的字符串中的特定元素

python - Matplotlib 中的字幕对齐问题

python - 什么是.so文件的库和包含目录变量?

image-processing - 如何用一种纯色填充 OpenCV 图像?

terminal - 刚刚安装了SASS,但是无法获取它的版本