Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install OpenCV for python

HI! I'm trying to install opencv and use it with python, but when I compile it I get no errors but I can't import cv module from python:

patrick:release patrick$ python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv

The code I used to compile it is this:

cd opencv
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON
make
sudo make install

how can I get it working with python?

like image 966
patrick Avatar asked Jul 24 '10 14:07

patrick


People also ask

How do I import OpenCV into Python?

Start the Python shell by typing python3 and then hit enter. You will be inside the Python shell where you can execute your Python code. Import the cv2 package which is the name of the OpenCV module. Type “import cv2” and hit enter.

Can I install OpenCV using pip?

OpenCV can be installed using pip.


1 Answers

brew tap homebrew/science
brew install opencv
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
like image 114
Lri Avatar answered Sep 28 '22 18:09

Lri