sudo apt-get python-opencv fetching different version than expected

sudo apt-get install python-opencv installs a .so file corresponding to opencv2.4.x, but I want the lib corresponding to opencv3.1.

Detailed context:

I am learning openCV3.1. Everything for running a opencv example is complete and when I run a sample python script, which is using a library cv2.so, I realized that the program is giving runtime error because of an incorrect version of cv2.so (cv2.so installed corresponding to 2.4.9 version of openCV, I wanted cv2.so corresponding to 3.1 version). So, I think the issue is in apt-get sources/config files etc which I need help to resolve.

Below content might be useful to understand, Output of sudo apt-get download python-opencv :

Get:1 xenial/universe amd64 python-opencv amd64 2.4.9.1+dfsg-1.5ubuntu1 [310 kB]
Fetched 310 kB in 21s (14.6 kB/s)
W: Can't drop privileges for downloading as file '/home/bhargav/python-opencv_2.4.9.1+dfsg-1.5ubuntu1_amd64.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
2

2 Answers

Well for your information the opencv version in Xenial is only 2.4.9 details as follows :

 python-opencv: Installed: (none) Candidate: 2.4.9.1+dfsg-1.5ubuntu1 Version table: 2.4.9.1+dfsg-1.5ubuntu1 500 500 xenial/universe amd64 Packages

Your require opencv 3.1 , well you need to install a bunch of things which can be found in other blogs. I am not gonna write all those here rather I can show you links because its very well explain over there.Link here. You can follow it in your Ubuntu 16.04.

4

You can install OpenCv for Python from PyPI (python package index):

  1. Uninstall previous version
  2. Make sure your pip is up to date: pip install -U pip
  3. Install opencv-python: pip install opencv-python
  4. import cv2
  5. Check version: cv2.__version__

This works also with virtualenvs.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like