I am fighting to install png and EBImage R package on my linux centos 7 machine. I have always this error message:

    Error: package or namespace load failed for ‘png’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/rico/R/x86_64-redhat-linux-gnu-library/3.6/00LOCK-png/00new/png/libs/png.so':
  libpng16.so.16: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/rico/R/x86_64-redhat-linux-gnu-library/3.6/png’
Warning in install.packages :
  installation of package ‘png’ had non-zero exit status

The downloaded source packages are in

I tried to do:

yum install libpng-devel

and it output me:

Package 2:libpng-devel-1.5.13-7.el7_2.x86_64 already installed and latest version
Nothing to do

Any idea how to solve this issue ? Thanks.

  • Do you also have Anaconda installed on your machine? – Mark Nielsen May 21 '20 at 5:29
  • Hi Mark, yes I have Anaconda 3 installed. Finally, I managed to install EBImage on my Linux centos 7 machine. sudo cp /usr/local/lib/libpng16.so.16 /usr/lib – user979974 May 25 '20 at 7:47
  • 1
    I had the same issue. Once I removed anaconda from the path it was able to install the png package with no issues. – Mark Nielsen May 26 '20 at 23:46

It looks like your R package needs libpng16.so.16 (1.6. branch) whereas the default on CentOS 7 is the one you installed (1.5 branch, available via libpng package).

If you don't mind using a commercial repository, libpng 1.6 is available at GetPageSpeed repo:

sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm
sudo yum install libpng16

Alternatively, although highly discouraged due to placing non-packaged files on the root filesystem, you can use precompiled binaries of libpng16 located here: extract the archive, create symlink from the precompiled library file over to libpng16.so.16, provide custom include path from the archive to the R package installation, etc...

  • Hi Danila, thank you very for your help. I gonna use precompiled binaries of libpng16. Can you tell me how do you create a symlink from the precompiled library file over to libpng16.so.16? I gotta to search how to provide a custom include path to R package installation. That's a liltle bit new for me. – user979974 Mar 17 '20 at 13:06
  • cd /path/where/it/is/extracted && ln -s libpng16.so.16.37.0 libpng16.so.16 that would be a mere equivalent of what a libpng16-devel package would install (unversioned soname file). – Danila Vershinin Mar 17 '20 at 13:09

For some reason having Anaconda on RHEL/Centos 7 causes this issue. Probably because Anaconda installs a more recent version of libpng.

I was able to get another package installed that had the same png package dependency by temporarily removing anaconda from the PATH recognized by R. Once I did this, the png package and its dependent package installed with no issues.


I managed to install EBImage on my Linux centos 7 machine. sudo cp /usr/local/lib/libpng16.so.16 /usr/lib resolved the issue

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.