2

I tried to install opencv and python with port and brew. but when i try import cv it says "module not found".

i have the same problem on my windows machine and just no solution works. is there a simple step by step solution for someone who does not know all the terminal codes? im not really a good programmer but it would be awsome to get this working.

--edit--

got it working on Windows and Mac

Mac: First uninstalled Homebrew and MacPort restarted, installed Macport again. then :

sudo port install opencv +universal +python26

after that i just had to install numpy.

Win7

installed

python-2.7.2.msi
OpenCV-2.2.0-win32.exe
opencv-python-2.2.0.win32-py2.7.exe
numpy-1.6.0-win32-superpack-python2.7.exe
dichterDichter
  • 315
  • 7
  • 16

2 Answers2

4

When using brew, try brew info opencv, which explicitly tells you:

The OpenCV Python module will not work until you edit your PYTHONPATH like so: export PYTHONPATH="/usr/local/lib/python2.6/site-packages/:$PYTHONPATH"

The export thing should go into your shell config. You could put this into ~/.bashrc, but the truly system-wide setting would need to be set otherwise (try Setting environment variables in OS X?).

Or else, in your python script:

import sys
sys.path.insert(0, "/usr/local/lib/python2.6/site-packages/")
import cv

Then it should work.

Community
  • 1
  • 1
Piotr Kalinowski
  • 2,272
  • 1
  • 14
  • 15
0

Easiest way (imo) is using macports - once you did setup macports, installing opencv with python is:

port install opencv +python27

(you may need to uninstall opencv first if you already installed it without python support), Then use macport's python (not the system one) - should be in /opt/local/bin/python2.7, you can add that to your path so you don't need to type the full one.

etarion
  • 16,935
  • 4
  • 43
  • 66