1

I already have part of a program running in Python 3 but I need OpenCV (or SimpleCV), for a robotic vehicle, but I haven't found any install commands that seem to work, other than for Python 2.7.

If it is compatible could you please include instructions (/links to) for installation of the module?

I am using Ubuntu 14.

Michael Currie
  • 13,721
  • 9
  • 42
  • 58
  • 1
    i don't think, that it supports python3.x. cv2 is all c++ (wrapper)code, and was probably linked against python2.7.x – berak Jun 25 '14 at 18:14

2 Answers2

0

Maybe a little late to answer, but it's actually supported on OpenCV version 3 (in alpha state nowadays). I have successfully managed to install it, on MacOS, but I guess it would be similar on Ubuntu. Now you have separated options for python2 and python3 when using Cmake. So you'll have to set those to make it work. That's all I needed to set:

  • BUILD_opencv_python3
  • PYTHON3_LIBRARY
  • PYTHON3_INCLUDE_DIR
  • PYTHON3_INCLUDE_DIR2
  • PYTHON3_NUMPY_INCLUDE_DIRS
  • ...

Here you can find more detailed description: Link

Luigolas
  • 366
  • 2
  • 9
0

Luigolas is correct that OpenCV 3.0 supports Python 3.x bindings. It was in release candidate status since April and the production version was released on 4 June 2015. Unfortunately for some reason the downloadable installation program on the OpenCV site does not contain a Python 3.x-compatible cv2.pyd file.

OP asked about Ubuntu but for those requiring a Windows installer, use Christoph Gohlke's site, which maintains Windows binaries for many Python packages, including OpenCV 3.0 with Python 3.x bindings. Visit:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv

To install, just download the 64-bit or 32-bit .whl file appropriate for your system, then run pip install [filename]. Then the instruction import cv2 should work in your Python 3.x interpreter.

Michael Currie
  • 13,721
  • 9
  • 42
  • 58
  • I've seen, you've provided the "same" answer to three question ([1](http://stackoverflow.com/questions/26489867/opencv-for-python-3-x-under-windows), [2](http://stackoverflow.com/questions/22709407/opencv-for-python-3-x)). Those are similar. You should've posted only one answer to the best question and flagged the other questions as a duplicate of that question. Please don't repost essentially the same answer to multiple questions. – Artjom B. Jun 06 '15 at 20:10
  • None of the questions seemed like straight-up duplicates to me, and have not yet been flagged as such. However, if they are duplicates, I suppose you are right, I should only post the answer in one place. Thanks – Michael Currie Jun 06 '15 at 22:14