Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV in python on mac installation with homebrew

Tags:

python

opencv

I'm trying to get opencv for python on my mac running mavericks. After googling/stack overflow seraching I tried:

brew install homebrew/science/opencv

Based on the terminal output it looks like that worked.

To verify I wrote a python script that simply contains:

import cv2

print("Hello")

I get no module named cv2. When I try looking at the installed modules by typing help('modules') I don't see cv or cv2. This leaves me with two conclusions: either I didn't properly install opencv or import cv2 isn't actually importing cv2 and python is looking in the wrong location for cv2. Any suggestions would be appreciated.

like image 877
Doov Avatar asked Dec 22 '25 04:12

Doov


1 Answers

According to this guide, if you add the following to your .bash_profile it should fix your issue:

export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
like image 124
Bioto Avatar answered Dec 23 '25 21:12

Bioto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!