Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Homebrew installation of OpenCV 3.0 not linking to Python

When I install OpenCV 3.0 with Homebrew, it gives me the following directions to link it to Python 2.7:

If you need Python to find bindings for this keg-only formula, run:
echo /usr/local/opt/opencv3/lib/python2.7/site-packages >> /usr/local/lib/python2.7/site-packages/opencv3.pth

While I can find the python2.7 site packages in opencv3, no python34 site packages were generated. Does anyone know how I can link my OpenCV 3.0 install to Python 3?

like image 329
Jack Simpson Avatar asked Dec 19 '22 00:12

Jack Simpson


2 Answers

It's weird that there is no concise instruction for installing OpenCV 3 with Python3. So, here I make it clear step-by-step:

  1. Install Homebrew Python 3.5: brew install python3
  2. Tap homebrew/science: brew tap homebrew/science
  3. Install any Python3 packages using pip3. This will create the site-packages folder for Python3 For example: pip3 install numpy

  4. Then install OpenCV3 brew install opencv3 --with-python3

  5. Now you can find the site-packages folder created in Step 2. Just run the following command to link Opencv3 to Python3: echo /usr/local/opt/opencv3/lib/python3.5/site-packages >> /usr/local/lib/python3.5/site-packages/opencv3.pth

You may have to change the above command correpondingly to your installed Homebrew Python version (e.g. 3.4).

like image 112
Minh Nguyen Avatar answered Dec 21 '22 12:12

Minh Nguyen


You need to install opencv like brew install opencv3 --with-python3. You can see a list of options for a package by running brew info opencv3.

like image 41
Tim Smith Avatar answered Dec 21 '22 13:12

Tim Smith