Libpng15.so error while importing matplotlib

So, here I was trying my hands on ipython notebook, when the following commands generated an error.

import matplotlib.pyplot as plt
AND
import numpy as np

At first I thought it was due to some configuration issues with my notebook but when I tried the above commands on python via terminal, the same error surfaced.

ImportError: libpng15.so.15: cannot open shared object file: No such file or directory

It looked like either some files were missing or the interpreter was looking for them somewhere else.

Following the solutions on Stackoverflow-

Check the value of LD_LIBRARAY_PATH, do:
echo $LD_LIBRARAY_PATH
As expected, it returned an empty string, which meant I had to change its value.
Change the value of LD_LIBRARAY_PATH,do:
export LD_LIBRARAY_PATH=:$LD_LIBRARAY_PATH
In my case it was /home/sarah/anaconda/lib, you can check for yours using
locate libping15.so.15

The solution did not work for me, in fact it is a temporary one, once the system is switched off, the exported path would be lost. You can make it permanent by adding the above line at the end of your .bashrc file and then running:

source .bashrc

Caution! appending the above lines to my .bashrc, rendered useless running my text editors from the terminal,

So I had to redo the changes. Looked like things were real bad.

I had two more option before me, to either install/reinstall the libpng from package manager or do it manually.
Shortcuts first,

sudo apt-get install zlib1g-dev
sudo apt-get install libpng-dev
sudo apt-get update

With hopes that my system will resolve the missing links, now that it had been updated. But, it did not, because the package manager still used the libping12 while I needed  libpng15.

Left will no other option,here is what finally worked:

D/w the latest tar of libpng
Un-tar it and move inside the folder
./configure
make
sudo make install
sudo ln -s /usr/local/lib/libpng15.so /usr/lib
OR
sudo ln -s /usr/local/lib/libpng15.so.15 /usr/ib

Testing time:

$ subl (opened without error)
Fingers crossed
$ python
>>import matplotlib.pyplot as plt
>>

No errors.
Phew!!

Credits:Shivam 😉

Advertisements

2 thoughts on “Libpng15.so error while importing matplotlib

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s