安装 ncdf4 包:错误,找不到 nc-config 或不可执行

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

我已经尝试安装 ncdf4 包。我有 R 版本 3.1.1.

问题似乎是找到 nc-config。如果我 Google 针对这个特定问题,那么我会找到有同样问题的人,他们通过在安装 ncdf4.

之前安装 Debian 软件包 libnetcdf-dev 解决了这个问题

我已经安装了那个包,但我一直遇到同样的问题,

错误如下:

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.

正如@PaulHiemstra 在评论中提到的,找出你的 nc-config 在哪里:

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.\

对我来说,是:

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

我开始使用以下命令安装 netcdf essentials

sudo apt-get install r-cran-ncdf4

上面的命令应该已经安装了 nc-config,如果没有请尝试:

sudo apt-get install netcdf-bin

现在,下载 netcdf4 源代码

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

现在,尝试安装

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

在 CentOS 7 上,在终端中使用 sudo yum install netcdf-devel.x86_64 就可以了。

我遇到了类似的问题,这些答案对我来说不太适用 (Ubuntu 16.04.4 LTS)。

我必须使用以下方法安装开发人员版本:

sudo apt-get install libnetcdf-dev

我也遇到同样的问题,不过你需要安装

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

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

这将解决问题