'Issues installing opencv 3.2 on python 3.6

How can i install OpenCV 3.2 in linux?

Firstly, conda install -c menpo opencv3=3.2.0 installs but gives this import error:

File "<stdin>", line 1, in <module> ImportError: libpng12.so.0: cannot open shared object file: No such file or directory

Which i cannot fix. I've tried to use sudo apt install libpng12-0 but my remote server doesn't use a sudoers file.

I've also tried other methods such as conda install opencv=3.2.0, conda install -c conda-forge opencv=3.2.0, conda install -c conda-forge opencvetc... but these don't seem to install properly and give me errors.



Solution 1:[1]

For me, in Ubuntu 19.10, I have a libpng16.so in /usr/lib/x86_64-linux-gnu/.

I found where it was by typing locate libpng in a terminal. It's a newer version, so that might be giving you the problems you're having.

Without any information on your remote server, it's a little hard to predict where it might be. You may find it in /usr/lib/, or /usr/local/lib/. You could also try the working directory (or executable directory, haven't tried that) as a quick and dirty solution. If you don't have admin rights, it might be worth sending an email/opening a ticket with someone who does, who could point you in the right direction (if you have to load specific modules to get that version of the library in the path, etc).

If you're brave and stupid, you could also set the LD_LIBRARY_PATH variable to include whatever folder you put the library in.

Solution 2:[2]

Install all the following packages in step 2 of this link. Then restart your machine and try importing cv2 again.

Mostly the remote machine wont have any video drivers like x-org etc or any GUI or visual support for PNG or JPEG etc. So such an issue can occur.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Andy_101