“如何安装R软件包”;RNetCDF“;及;ncdf“;在Ubuntu上?

“如何安装R软件包”;RNetCDF“;及;ncdf“;在Ubuntu上?,r,installation,deb,netcdf,R,Installation,Deb,Netcdf,我想在Ubuntu中使用R包RNetCDF和ncdf 当我尝试install.packages('RNetCDF')或install.packages('ncdf')时,我会遇到类似的错误: ... ncdf.c:3:20: fatal error: netcdf.h: No such file or directory compilation terminated. make: *** [ncdf.o] Error 1 ERROR: compilation failed for package

我想在Ubuntu中使用R包RNetCDF和ncdf

当我尝试
install.packages('RNetCDF')
install.packages('ncdf')
时,我会遇到类似的错误:

...
ncdf.c:3:20: fatal error: netcdf.h: No such file or directory
compilation terminated.
make: *** [ncdf.o] Error 1
ERROR: compilation failed for package ‘ncdf’
...
Warning message:
In install.packages("ncdf") :
  installation of package ‘ncdf’ had non-zero exit status

Ubuntu存储库中的包
libnetcdf6
netcdf-bin
已安装。我还需要做点别的吗

您需要安装这些包的
-dev
,以获取编译包所需的头文件。在本例中,您需要
libnetcdf-dev
udunits-bin
libudunits2-dev
,在我的示例中,需要libudunits2-dev包

sudo apt get安装libudunits2 dev

因为我是从源代码安装NetCDF的,所以我必须手动指定lib和include文件夹的位置


我只是想澄清一下,因为您最初的问题是在R中,而修复程序是在R之外应用的。我最初试图这样做

install.packages(“libnetcdf-dev”),它不起作用

相反,从R:sudo外部获取安装libnetcdf dev


在Ubuntu 20.04 LTS中,可以使用bash命令sudo apt install r-cran-ncdf4安装ncdf4包(包括所有依赖项)。同样,对于RNetCDF,您可以使用
sudo apt安装r-cran-RNetCDF

您需要安装这些包的
-dev
,以获取编译包所需的头。@Justin谢谢。
ncdf
所需的唯一附加软件包是
libnetcdf dev
用于
RNetCDF
udunits bin
libudunits2 dev
,以便安装ncdf4软件包(ncdf软件包的更新),我还需要运行
sudo-apt-get-install-netcdf-bin
?这个答案已经有7年了,它仍然需要某种烫发修复。
install.packages("/home/user/Downloads/RNetCDF_1.6.1-2.tar.gz", 
repos = NULL,
type="source",
dependencies=FALSE,
configure.args="--with-netcdf-include=/usr/local/netcdf-4.2.1-build/include --with-netcdf-lib=/usr/local/netcdf-4.2.1-build/lib")