13

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.
zx8754
  • 52,746
  • 12
  • 114
  • 209
Santiago I. Hurtado
  • 1,113
  • 1
  • 10
  • 23
  • 2
    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.\ – Paul Hiemstra Mar 19 '17 at 19:24

5 Answers5

33

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
Oatman
  • 431
  • 4
  • 4
10

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

F. Privé
  • 11,423
  • 2
  • 27
  • 78
8

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"
zx8754
  • 52,746
  • 12
  • 114
  • 209
Aji
  • 133
  • 1
  • 5
0

I also face the same issue, but you need to install

sudo apt install libgdal-dev libproj-dev libgeos-dev libudunits2-dev libnode-dev libcairo2-dev libnetcdf-dev

and

sudo apt install libglu1-mesa-dev freeglut3-dev mesa-common-dev

This will solve the issue

user35078
  • 5
  • 2
0

Using conda may a good option conda install -c anaconda netcdf4

upuil
  • 67
  • 2
  • 8