24

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 ?

mjm
  • 723
  • 3
  • 6
  • 16
  • 1
    You could look up the package name with: `apt-cache search libjasper` or `apt-cache search jasper` – eyllanesc Apr 19 '17 at 02:02
  • 1
    @eyllanesc The package doesnt seems to be available for Ubuntu 17.04. Please check this link. http://packages.ubuntu.com/search?keywords=libjasper-dev – mjm Apr 19 '17 at 09:55

5 Answers5

44

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.

headdab
  • 1,040
  • 9
  • 10
  • affirmed on lubuntu 17.10 – gkhaos Mar 08 '18 at 08:51
  • 8
    not worked in Ubuntu 18.04 for me. I got 404 Not Found error for http://security.ubuntu.com/ubuntu xenial-security/main arm64 Packages – dolgom Jun 21 '19 at 19:04
  • worked in 18.04 for me when I tried to install opencv – Chau Giang Dec 24 '19 at 11:12
  • 5
    `Ign:9 http://security.ubuntu.com/ubuntu xenial-security/main arm64 Packages` `Ign:9 http://security.ubuntu.com/ubuntu xenial-security/main arm64 Packages` `Err:9 http://security.ubuntu.com/ubuntu xenial-security/main arm64 Packages` `404 Not Found [IP: 91.189.91.26 80]` – gone Feb 27 '20 at 23:23
  • 1
    is there any really working solution for this? – cagri Feb 28 '21 at 16:00
16

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.

mjm
  • 723
  • 3
  • 6
  • 16
  • Rebuilding your opencv disabling jpeg2000 support would work as well. Building opencv is usually the most powerful way of installing it, see http://stackoverflow.com/questions/26592577/installing-opencv-in-ubuntu-14-10?rq=1 (votes strongly converged to the "build it yourself" version) – Antonio Apr 20 '17 at 07:54
  • 1
    tnx for this answer! – Ofer Sadan Jun 05 '17 at 17:48
  • 1
    awesome :D. worked for me as well, after struggling for 2 hrs with other methods. – Bms bharadwaj Jul 23 '19 at 15:11
14

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
chittychitty
  • 419
  • 5
  • 12
  • Having the dependencies issues in version 17.xx, still a good try – Shameerariff Jul 28 '17 at 17:11
  • 4
    This did not work on Ubuntu 18.04. The below answer does, however. –  Jun 02 '18 at 19:38
  • 2
    sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main" ; sudo apt update ; sudo apt install libjasper1 libjasper-dev works on Ubuntu 18.04 – sirop Oct 11 '18 at 19:33
  • 1
    Malformed entry 54 in list file /etc/apt/sources.list (URI parse) after @sirop command performed – A.Ametov Apr 11 '19 at 08:26
  • 3
    Try it with single quotes: `sudo add-apt-repository 'deb http://security.ubuntu.com/ubuntu xenial-security main'` or manually edit /etc/apt/sources.list . – sirop Apr 11 '19 at 09:12
  • 1
    'us.archive.ubuntu.com' should be 'old-releases.ubuntu.com' – dolgom Jun 21 '19 at 18:43
0

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

0

Write this Down, it is really helpful,

echo "deb http://us.archive.ubuntu.com/ubuntu/ yakkety universe" | sudo tee -a /etc/apt/sources.list
Krunal V
  • 1,255
  • 10
  • 23