Install ncdf4 package: Error, nc-config not found or not executable

13,590

Solution 1

As @PaulHiemstra mentioned in the comments, find out where your nc-config is:

What you can do is open a fresh terminal and do which nc-config. This will show you where the file is actually located in your system. If this file is indeed installed, the problem is probably that Linux installs it in a given location, and R expects it somewhere else (/usr/local/bin vs /usr/bin for example). You can try to fix the issue by adding the library containing nc-config to your PATH environment variable. Or the problem could be unrelated, e.g. 32 bit vs 64 bit.\

For me, it is:

ubuntu@dark-horse:~$ which nc-config 
/home/ubuntu/miniconda3/bin/nc-config

I start with installing netcdf essentials using the below command

sudo apt-get install r-cran-ncdf4

The above command should have gotten nc-config installed, if not try:

sudo apt-get install netcdf-bin

Now, download the netcdf4 source

wget http://cirrus.ucsd.edu/~pierce/ncdf/ncdf4_1.13.tar.gz

Now, try to do the install

sudo R CMD INSTALL ncdf4_1.13.tar.gz --configure-args="--with-nc-config=/home/ubuntu/miniconda3/bin/nc-config"

Solution 2

I was having a similar problem and these answers didn't quite work for me (Ubuntu 16.04.4 LTS).

I had to install the developer version using:

sudo apt-get install libnetcdf-dev

Solution 3

On CentOS 7, using sudo yum install netcdf-devel.x86_64 in a terminal did the trick.

Share:
13,590
Santiago I. Hurtado
Author by

Santiago I. Hurtado

I am PhD. student at National University of La Plata (UNLP), Argentina. My PhD is about precipitation variability in north Argentina. I am also a teacher at UNLP in Dynamics and Statistical Methods.

Updated on June 09, 2022

Comments

  • Santiago I. Hurtado
    Santiago I. Hurtado about 2 years

    I have tried to install ncdf4 package. I have R version 3.1.1.

    The problem seems to be finding the nc-config. If I Google for this specific problem, then I find people with the same problem, who solved it by installing the Debian package libnetcdf-dev before installing ncdf4.

    I already installed that package but I keep having the same problem,

    The error is as follows:

    checking for nc-config... no
    -----------------------------------------------------------------------------------
    Error, nc-config not found or not executable.  This is a script that comes with the netcdf library, version 4.1-beta2 or later, and must be present for configuration to succeed.
    
  • fvfaleiro
    fvfaleiro almost 5 years
    It works for me in the Ubuntu 18.04 and R version 3.4.4 (2018-03-15).
  • dez93_2000
    dez93_2000 over 4 years
    and 19.10, 3.6.1
  • Jeremy Caney
    Jeremy Caney about 4 years
    Contributor @Faith-Jones reports that this also works in Ubuntu 20.04.
  • Feng Tian
    Feng Tian almost 4 years
    yum install netcdf-devel
  • Mohamed Ismaiel Ahmed
    Mohamed Ismaiel Ahmed over 3 years
    That works for me on Linux Mint 20.1 “Ulyssa”! Thanks!