Failed installation of package "ncdf4" in R studio - r

I'm trying to install an R package called "ncdf4".
I've tried installing it in the "packages" section in the R-studio interface, but have also tried entering install.packages("ncdf4") into the console.
This is the output I get in both instances:
Installing package into ‘/home/user/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/ncdf4_1.17.tar.gz'
Content type 'application/x-gzip' length 124458 bytes (121 KB)
==================================================
downloaded 121 KB
* installing *source* package ‘ncdf4’ ...
** package ‘ncdf4’ successfully unpacked and MD5 sums checked
** using staged installation
configure.ac: starting
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.
If you installed the netcdf library (and nc-config) in a standard location, nc-config
should be found automatically. Otherwise, you can specify the full path and name of
the nc-config script by passing the --with-nc-config=/full/path/nc-config argument
flag to the configure script. For example:
./configure --with-nc-config=/sw/dist/netcdf4/bin/nc-config
Special note for R users:
-------------------------
To pass the configure flag to R, use something like this:
R CMD INSTALL --configure-args="--with-nc-config=/home/joe/bin/nc-config" ncdf4
where you should replace /home/joe/bin etc. with the location where you have
installed the nc-config script that came with the netcdf 4 distribution.
-----------------------------------------------------------------------------------
ERROR: configuration failed for package ‘ncdf4’
* removing ‘/home/user/R/x86_64-pc-linux-gnu-library/3.6/ncdf4’
Warning in install.packages :
installation of package ‘ncdf4’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpXcbO2y/downloaded_packages’
Is anybody able to decipher what went wrong from the code that I've provided?
Thanks.

I am using Ubuntu 20.4 and ran into the same problem.
Step 1: in the terminal
sudo apt-get update -y
Step 2: in the terminal
sudo apt-get install -y libnetcdf-dev
Step 3: in rstudio
install.packages("ncdf4")
After that ncdf4 was installed successfully
Reference:
https://zoomadmin.com/HowToInstall/UbuntuPackage/libnetcdf-dev

I finally managed to install ncdf4.
I read a similar problem here:
https://r.789695.n4.nabble.com/Problem-installing-ncdf-library-td4646986.html
I installed all the libnetcdf packages in the linux terminal by typing:
sudo apt install libnetcdf-*

If you are running Ubuntu18.04 or a derived version of it, you can look for the library netcdf4.1 by doing:
sudo apt-cache search libnetcdf
In my session (Linux Mint), I get:
libnetcdf-c++4 - legacy NetCDF C++ interface
libnetcdf-c++4-1 - C++ interface for scientific data access to large binary data
libnetcdf-c++4-dbg - debugging symbols for NetCDF C++
libnetcdf-c++4-dev - creation, access, and sharing of scientific data in C++
libnetcdf-c++4-doc - NetCDF C++ API documentation
libnetcdf-cxx-legacy-dbg - debugging symbols for legacy NetCDF C++ interface
libnetcdf-cxx-legacy-dev - legacy NetCDF C++ interface - development files
libnetcdf-dev - creation, access, and sharing of scientific data
libnetcdf13 - Interface for scientific data access to large binary data
libnetcdff-dbg - debugging symbols for NetCDF Fortran
libnetcdff-dev - creation, access, and sharing of scientific data in Fortran
libnetcdff-doc - NetCDF Fortran documentation
libnetcdff6 - Fortran interface for scientific data access to large binary data
So, installing the libnetcdf-c++4-1 should solve your issue:
sudo apt-get update
sudo apt-get install libnetcdf-c++4-1
Does it answer your question ?

For Arch Linux users, you probably haven't installed netcdf. You can use pacman to install netcdf
sudo pacman -S netcdf

just install netcdf via apt
apt-get install libnetcdf-dev
it worked for me (ubuntu 20.04 and R 4)

Related

Installing R on Hortonworks Sandbox hadoop 2.3

I’m experiencing some troubles when I try to install R dependencies with the command :
install.packages(c(“Rcpp”,”RJSONIO”,”bitops”,”digest”,”functional”,”itertools”,”reshape2″,”string ”,”plyr”,”caTools”),repos=’http://cran.revolutionanalytics.com’)
packages are downloaded but then all I get are the messages
/usr/lib64/R/bin/R: line 8: uname: command not found
/usr/lib64/R/bin/R: line 143: exec: sh: not found
repeated as many times as the number of packages I am trying to install.
I am using R version 3.2.2, rstudio-server 0.99.489 in Hortonworks Sandbox with hadoop 2.3 (Oracle Virtualbox).
Do you have any suggestions?
Thanks for your help.
I know this question was asked 7 months ago. But I just had the same problem stefanod did and I Googled left and right without finding a solution. Then for absolutely no reasonable reason it just worked. Here is what I have tried and what eventually solves my problem:
So I use R 3.2.2, rstudio-server 0.98.994 in Hortonworks Hadoop Sandbox HDP 2.4 in VMWare. I logged in the virtual machine using the Shell Web Client Method. The entire process was done with root privilege. I followed this instruction: https://jsolderitsch.wordpress.com/hortonworks-sandbox-r-and-rstudio-install/ except that I used updated versions of R and RStudio Server. Everything worked fine until I invoked R in the shell and attempted
install.packages('foo.bar', repos='http://cran.revolutionanalytics.com')
Then I had exactly the same error messages as in this Q.
I checked my $PATH and used whereis COMMANDNAME to check if I had the uname command at the right place. Seems I do.
I then quit R. Inside CentOS I used wget to manually download the .tar.gz files of the packages and their dependencies. I then tried to install those packages manually:
[root#sandbox ~]# sudo R CMD INSTALL foo.bar.tar.gz
* installing to library ‘/usr/lib64/R/library’
* installing *source* package ‘foo.bar’ ...
** package ‘foo.bar’ successfully unpacked and MD5 sums checked
** libs
sh: make: command not found
ERROR: compilation failed for package ‘foo.bar’
* removing ‘/usr/lib64/R/library/foo.bar’
sh: rm: command not found
At this time RStudio was already installed. So I logged into RStudio in my browser at port 8787 and tried install.packages in RStudio and every package installed fine.
I guess the take-home message is to install packages inside RStudio instead of inside R in the shell.
BTW I also cannot log in RStudio as root; says invalid username and password.

Error installing RMySQL

It took a good amount of time to install RMySQL on my Linux machine but I was able to install it after changing environment variables and copy and paste lib.dll file.
However, I'm now trying to install RMySQL on my 64bit window machine, but so far there's no progress yet for two days. It broke down after "running command sh ./configure.win had status 127 error, and I cannot find what this means.
Can anyone shed some lights on this?
install.packages('RMySQL',type='source')
Installing package into ‘C:/Users/chu/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/RMySQL_0.9-3.tar.gz'
Content type 'application/x-gzip' length 165363 bytes (161 Kb)
opened URL
downloaded 161 Kb
* installing *source* package 'RMySQL' ...
** package 'RMySQL' successfully unpacked and MD5 sums checked
Warning: running command 'sh ./configure.win' had status 127
ERROR: configuration failed for package 'RMySQL'
* removing 'C:/Users/chu/Documents/R/win-library/3.1/RMySQL'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-31~1.0/bin/x64/R" CMD INSTALL -l "C:\Users\chu\Documents\R\win-library\3.1" C:\Users\chu\AppData\Local\Temp\RtmpKA9e7I/downloaded_packages/RMySQL_0.9-3.tar.gz' had status 1
Warning in install.packages :
installation of package ‘RMySQL’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\chu\AppData\Local\Temp\RtmpKA9e7I\downloaded_packages’
for linux users..
install- libmysql first
sudo apt-get install libmysql++-dev
then try.
I was facing the same error. Given below is the link to a way around that worked for me.
http://www.ahschulz.de/2013/07/23/installing-rmysql-under-windows/
In short, the location of library libmysqll.dll required for compilation, had to be changed from lib folder to bin folder of the home directory set for MySQL in environment variables.
By default, R uses the /tmp directory to install packages. On security conscious machines, the /tmp directory is often marked as “noexec” in the /etc/fstab file. This means that no file under /tmp can ever be executed. Packages that require compilation or that have self-inflating data will fail with the error mentioned.
The solution is to set the TMPDIR environment variable outside R (in your shell), which R will use as the compilation directory. How to do this depends on the shell. bash:
mkdir ~/tmp
export TMPDIR=~/tmp
Then R can compile and install the package.
I ran into the same problem while updating packages on Windows server for latest version of R. I solved it by installing from a .zip file vs .tar.gz.
I actually had to go through the process of first downloading the package, and then installing from it (not from mirror) for other reasons.
Here is what it looked like:
pk <- 'caTools'
download.packages(pk, "R-3.2-packages/" ,type = "win.binary")
install.packages(
dir("R-3.2-packages/",pattern=pk,full.names = TRUE),
repos = NULL,
type = "source")
Hope this helps.
Solution if anyone faced the same problem on windows:
Make sure your MYSQL_HOME environment variable is set correctly and libmysql.dll is copied to bin folder!!!
Run install.packages('RMySQL') then when the "Do you want to install from sources..." window pops up select No.
Then copy the downloaded binary packages location from console.
Go to Packages -> Install, paste the location into Package archive and click Install.

CRAN packages not unpacking on Ubuntu

Think I had done this type of command successfully before
sudo su ­ ­c "R ­e \"install.packages('countrycode', repos='http://cran.rstudio.com/')\""
the screen reports
Installing package into '/usr/local/lib/R/site-library'
which is where other packages reside
I then get
downloaded 28kb
and it just says that the source packages are in a tmp folder before returning to the prompt
This should work,
sudo R ­-e "install.packages('countrycode', repos='http://cran.rstudio.com/')"
You will be asked to type in your password and then it starts downloading and installation ...

R: Having trouble installing rpanel

I am trying to install the packages rpanel and tkrplot on RStudio. After downloading and installing there I got this message:
downloaded 686 Kb
* installing *source* package ‘rpanel’ ...
** package ‘rpanel’ successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** demo
** inst
** preparing package for lazy loading
Error in structure(.External(.C_dotTcl, ...), class = "tclObj") :
[tcl] can't find package BWidget.
Error : unable to load R code in package ‘rpanel’
ERROR: lazy loading failed for package ‘rpanel’
* removing ‘..../R/i686-pc-linux-gnu-library/3.0/rpanel’
Warning in install.packages :
installation of package ‘rpanel’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmp1MdC0f/downloaded_packages’
I already installed BWidget on my own, but it didn't help.
Anyone any ideas about this problem and maybe can help me?
The system is Ubuntu 12.04.
Under windows 7 there is no problem and everything is working fine.
There are easier ways to install BWidgets. On my mac with Macports I did:
sudo port install BWidget
On Ubuntu you can probably install it with apt-get:
sudo apt-get install bwidget
"Stumbled across this while looking for an answer to the same question. Like an unfortunate number of library authors, the BWidgets people have assumed that the only people who need to use their libraries are planning to code with them. For those of us who've never used TCL, the installation instructions mean nothing.
From the a document called tuto-install-tkabber on the tkabber.jabber.ru website (irritating spam catcher won't let me post a URL), the answer is:
Install the BWidgets directory into the "lib" directory returned by:
whereis tcl
It should look something like: /usr/lib/tcl8.4"
from http://www.linuxquestions.org/questions/linux-software-2/where-to-install-bwidget-tcl-98583/ did the trick for me
Also I got BWidget from: http://sourceforge.net/projects/tcllib/files/BWidget/1.7.0/BWidget-1.7.0.zip/download
#Calimo's answer worked for me on Linux Mint 18.3 RStudio R 3.6.0. I would have commented in #Calimo's thread except for the stupid 50 reputation limit.
sudo apt-get install bwidget
Also works for Ubuntu 18 R 3.4.4 but if you get an X11 issue with rgl then this helped from #Ouistiti.
I had similar issues trying to get biotools working in Rstudio (on Ubuntu 16.04), where rpanel and tkrplot are required. Even after installing Bwidget per Calimo's answer, I got the error installation of package ‘tkrplot’ had non-zero exit status because tk.h: No such file or directory. If you look in the directory, this error is definitely correct. You need to get tk.h in there. I found out how to do so elsewhere on stackexchange:
Install tcl-dev package using apt or synaptic; tcl contains the
runtime, while tcl-devel contains header and development files. Do the
same with tk-dev
from:
https://stackoverflow.com/a/9649478/10405322
Thus,
sudo apt-get install tcl-dev
sudo apt-get install tk-dev
download BWidget from
http://sourceforge.net/project/showfiles.php?group_id=12883
once you get the archive BWidget-1.7.0.tar.gz move it to /usr/local/lib and install it with following code in terminal:
sudo mv /some_download_path/BWidget-1.7.0.tar.gz /usr/local/lib
cd /usr/loca/lib
sudo tar zxf BWidget-1.7.0.tar.gz
ok, done.

R installation for RHive and/or RStudio("--enable-R-shlib")

I suspect I am having a problem with my R installation, something that has to do with "--enable-R-shlib".
Can someone explain if this is something that I can fix using apt-get?
More specifically:
I am having trouble getting installing the RHive package.
I Installed R from scratch, following the instructions in (for example):
http://cran.ru.ac.za/bin/linux/ubuntu/
basically, just doing:
sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-base-dev
Next I opened R and installed rJava:
install.packages("rJava")
which worked fine.
Next I tried installing RHive:
install.packages("RHive")
at which point the installation fails with the following message:
* installing *source* package ‘Rserve’ ...
** package ‘Rserve’ successfully unpacked and MD5 sums checked
checking whether to compile the server... yes
configure: error: R was configured without --enable-R-shlib or --enable-R-static-lib
*** Rserve requires R (shared or static) library. ***
*** Please install R library or compile R with either --enable-R-shlib ***
*** or --enable-R-static-lib support ***
What Should I Do?
Also, I installed RStudio and this fails at startup with a related message:
"R shared library (/usr/local/lib64/R/lib/libR.so) not found. If this is a custom build of R, was it built with the --enable-R-shlib option"
All of which leads me to believe it is all related to the same problem. Weird thing is, I followed the same procedure on a different machine, and all seems to work fine...
I had the same problem.
In my case I changed R_HOME like this Sys.setenv(R_HOME="/usr/lib/R")
R, as well as r-cran-rjava and r-cran-rserve are available for Debian and Ubuntu as part of the basic distribution.
Can you not use those packages? They certainly work for me and many, many other people at least as far as RStudio is concerned -- I have not tried RHive myself.

Resources