简体   繁体   English

无法在Mac上使OpenCV与Python一起使用

[英]Can't get OpenCV to work with Python on a Mac

I am having trouble getting OpenCV to work with Python on my Mac. 我无法在Mac上让OpenCV与Python一起使用。

I have tried installing it with MacPorts and with Cmake (which I installed from MacPorts) using the methods found at here: http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port . 我尝试使用以下位置的方法在MacPorts和Cmake(我从MacPorts安装)中安装它: http : //opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port I also had to download Xcode to make MacPorts work. 我还必须下载Xcode才能使MacPorts正常工作。

I ran sudo port -v install opencv +python27 and it seemed to work fine. 我运行了sudo port -v install opencv +python27 ,它似乎工作正常。 However when I tried to import OpenCV in Python using import cv , the module could not be found. 但是,当我尝试使用import cv在Python中导入OpenCV时,找不到该模块。

If any of this information helps, I have OSX 10.6.8 Snow Leopard, python 2.7.3, and am trying to install OpenCV 2.4.3. 如果这些信息有帮助,我有OSX 10.6.8 Snow Leopard,python 2.7.3,并正在尝试安装OpenCV 2.4.3。 I am not a very experienced programmer so my troubleshooting attempts are falling short of a solution. 我不是一个非常有经验的程序员,所以我的故障排除尝试没有解决方案。

Any help is appreciated. 任何帮助表示赞赏。 Thanks! 谢谢!

I haven't tried the MacPorts installation, but you might want to try this: 我没有尝试过MacPorts安装,但是您可能想尝试一下:

import cv2
from cv2.cv import *

I had the same problem, it seems that the OpenCV Python Bindings don't get installed without numpy preinstalled; 我遇到了同样的问题,似乎在没有预装numpy情况下无法安装OpenCV Python绑定。 you can use these commands: 您可以使用以下命令:

sudo port uninstall opencv
sudo port install py27-numpy
sudo port install opencv +python27

As in this question: How to install Python 2.7 bindings for OpenCV using MacPorts 就像这个问题一样: 如何使用MacPorts为OpenCV安装Python 2.7绑定

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM