1

I would like to install OpenCV with Python support on my Raspberry Pi for multiple versions of Python.

I am using the instructions at http://docs.opencv.org/3.1.0/d7/d9f/tutorial_Linux_install.html. When OpenCV builds, it automatically targets python 3.4. That is OK, but I would also like to also add support to Python 2.7.

I have seen instructions that utilize virtual environments (http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/), but don't want to use virtual environments.

How can I tell the OpenCV build / install to target specific or multiple versions of Python without using virtual environments? I assume there is a way to instruct CMake on what to build, but I know very little about how to use CMake.

1 Answer 1

1

I'm not sure if CMake has to do with this, but I first I installed Python 2.7

sudo apt-get install python2.7-dev

Then I targetted python 2 to the virtual environment I made mkvirtualenv cv -p python2

Afterwards, I checked and verified if it worked ls -l /usr/local/lib/python2.7/site-packages/

It should display something like this after:

total 1852 -rw-r--r-- 1 root staff 1895772 Mar 20 20:00 cv2.so

Link to the guide I used: http://www.pyimagesearch.com/2016/04/18/install-guide-raspberry-pi-3-raspbian-jessie-opencv-3/

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. I was hoping to get an answer that doesn't use virtual environments (see question), but maybe I need to just go with virtual environments.
Np, it's definitely a good idea to seperate them into virtual environments so they can have independent compilers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.