24
votes

I had OpenCV installed in my Ubuntu machine running Ubuntu 16.10. Recently I updated to the latest Ubuntu 17.04 and OpenCV failed to work.

I am getting the following error.

ImportError: libjasper.so.1: cannot open shared object file: No such file or directory

I tried to install libjasper. With the command sudo apt-get install libjasper-dev

But I am getting the error E: Unable to locate package libjasper-dev

How can I fix it ?

5
You could look up the package name with: apt-cache search libjasper or apt-cache search jasper - eyllanesc
@eyllanesc The package doesnt seems to be available for Ubuntu 17.04. Please check this link. packages.ubuntu.com/search?keywords=libjasper-dev - mjm

5 Answers

44
votes

I found the answer here: https://github.com/opencv/opencv/issues/8622

sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev

References to 17.04 packages no longer work.

15
votes

Installing the opencv library from the repository worked for me. Just both the following commands.

sudo apt-get install opencv-data 
sudo apt-get install libopencv-dev 

After installing that it worked as before. Previously I had build opencv myself. The one from the repository will work apparantely.

14
votes

libjasper-dev is not available for Ubuntu 17.04.

So you need to install the package from an earlier release. Try the following:

echo "deb http://us.archive.ubuntu.com/ubuntu/ yakkety universe" | sudo tee -a /etc/apt/sources.list

This will add a new line to the sources.list file in /etc/apt. It will allow installation of packages from 16.10.

You should be able to install the missing package libjasper-dev now with the following commands:

sudo apt-get update
sudo apt-get install libjasper-dev
0
votes

I had to download the new and updated, built version of opencv and success

0
votes

Write this Down, it is really helpful,

echo "deb http://us.archive.ubuntu.com/ubuntu/ yakkety universe" | sudo tee -a /etc/apt/sources.list