RPostgreSQL installation Error - RPostgreSQL.so: undefined symbol: PQpass - r

I am trying to install R-Package RPostgreSQL, but getting the following error,
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/lib64/R/library/RPostgreSQL/libs/RPostgreSQL.so':
/usr/lib64/R/library/RPostgreSQL/libs/RPostgreSQL.so: undefined symbol: PQpass
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/lib64/R/library/RPostgreSQL’
I have libpq and postgresql-dev installed. All the library files are in the directory
/usr/lib64/pgsql/ and all header files are in the directory
/usr/include/pgsql/
Postgre Version - 9.3.4
R Version - 3.0.2
Operating System - CentOS-6.4
I am missing some small thing, but unable to find out why this is happening.
What am I doing wrong? How to correct this?

Looks like the pgsql libraries are no longer installed in their previous locations. I linked both:
ln -s /usr/pgsql-9.3/lib /usr/lib/pgsql
ln -s /usr/pgsql-9.3/include /usr/include/pgsql
This worked for me :)

The package RPostgreSQL checks for PostgreSQL libraries only in the following directory paths,
/usr/lib
/usr/lib/pgsql
/usr/lib/postgresql
/usr/local/lib
/usr/local/lib/pgsql
/usr/local/lib/postgresql
/usr/local/pgsql/lib
/usr/local/postgresql/lib
/opt/lib
/opt/lib/pgsql
/opt/lib/postgresql
/opt/local/lib
/opt/local/lib/postgresql
/opt/local/lib/postgresql84
/sw/opt/postgresql-8.4/lib
/Library/PostgresPlus/8.4SS/lib
/sw/lib
It does not check for the directories either in LD_LIBRARY_PATH or in /etc/ld.so.conf.
So RPostgreSQL installation will be successful only if the PostgreSQL libraries exist in any of the above directories.
When I copied the libraries from /usr/lib64/pgsql to /usr/lib/pgsql and tried installing the package. It worked. :)

Related

Error installing RODBC or ODBC on a Sagemaker Jupyter NoteBook Instance

I have been trying to establish a connection to Teradata from a Sagemaker Jupyter Notebook instance. I was trying to do it the way I would through R Studio. But when ever I try to install the package in the instance I get an non-zero exit status error.
I have tried installing the following ways:
remotes::install_github()
or
devtools::install_github()
and also:
install.packages('odbc', repo="https://cran.rstudio.com/")
I tryed the same with RODBC, and I get the same warnings or errors.
Any ideas on how I can get around this problem?
Thanks in advance.
UPDATE:
If I run this line of code:
devtools::install_github("r-dbi/odbc")`
I get the following error (This is just an extract):
Error: Failed to install 'odbc' from GitHub:
System command error, exit status: 1, stdout + stderr (last 10 lines):
E> ** testing if installed package can be loaded from temporary location
E> Error: package or namespace load failed for ‘odbc’ in dyn.load(file, DLLpath = DLLpath, ...):
E> unable to load shared object '/tmp/RtmpBuMhbW/Rinst32846cdd20a9/00LOCK-odbc/00new/odbc/libs/odbc.so':
E> libodbc.so.2: cannot open shared object file: No such file or directory
E> Error: loading failed
E> Execution halted
E> ERROR: loading failed
E> * removing ‘/tmp/RtmpBuMhbW/Rinst32846cdd20a9/odbc’
E> -----------------------------------
E> ERROR: package installation failed
Traceback:
Alright, after hours of reading AWS/Sagemaker/Conda/R documentation I arrived at the conclusion that, I don't know how to explain the phenomena.
Nonetheless, I have found a workaround!
So we know how we can install packages through the Jupyter terminal or directly from a cell in the .ipynb file. Nonetheless, if you try to run those commands inside the R kernel just like you would on the terminal or in a Python kernel you would run into an error.
Also, for some people installing it in the terminal, or even on a Python kernel might just make conda install the package on a different environment. Yes, turns out there are a couple of environments on your Jupyter instance.
So, to get to the point, just like I said, you would use a conda install command, not a pip, sudo or yum command.
Make your life easier. Here is the code that you would need to run on your R Kernel cell, to install a package directly to the correct environment if, install.packages() and install_github() didn't work:
system(command = 'conda install -c r packageName --yes')
Example:
system(command = 'conda install -c r tidyverse --yes')
And that's it. After that you can call library() and resume your R workflow as you do.
Hope this helps guys!

R studio cannot find existing library

It seems that R studio cannot find a library (DirichletMultinomial.so)
I installed this library through R in command line. I had problem installing it with Rstudio, because this package requires gsl, which I compiled on my own (don't have sudo priviledge). I added the path of gsl libs to my $PATH and R command line was able to use it to install the packages. But Rstudio somehow still reports "gsl-config: command not found". It seems that Rstudio ignore my set up of $PATH completely and I have no idea how to fix it.
> library(TFBSTools)
Error: package or namespace load failed for ‘TFBSTools’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/bar/cfan/R/x86_64-pc-linux-gnu-library/3.5/DirichletMultinomial/libs/DirichletMultinomial.so':
libgsl.so.23: cannot open shared object file: No such file or directory
cfan#paleAle:~$ wc -l /bar/cfan/R/x86_64-pc-linux-gnu-library/3.5/DirichletMultinomial/libs/DirichletMultinomial.so
273 /bar/cfan/R/x86_64-pc-linux-gnu-library/3.5/DirichletMultinomial/libs/DirichletMultinomial.so

ROracle not loading Instantclient library on MacOS High Sierra

I have installed Oracle Instant Client 12.1.0.2.0 and am now trying to install ROracle 1.3-1 for R with the following command:
R CMD INSTALL --configure-args='--with-oci-lib=/usr/local/oracle/instantclient12 --with-oci-inc=/usr/local/oracle/instantclient12/sdk/include' ROracle_1.3-1.tar.gz
The Oracle Instant Client is installed in /usr/local/oracle/instantclient12
Unfortunately, I am getting the following error at the end of the ROracle install and have been having a difficult time figuring out what is going wrong:
** testing if installed package can be loaded
Error: package or namespace load failed for ‘ROracle’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/ROracle/libs/ROracle.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/ROracle/libs/ROracle.so, 6): Library not loaded: #rpath/libclntsh.dylib.12.1
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/ROracle/libs/ROracle.so
Reason: image not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/ROracle’
For whatever reason #rpath/libclntsh.dylib.12.1 can't be found and is preventing ROracle from being fully installed. I have tried putting a link to libclntsh.dylib.12.1 in ~/lib and /usr/lib but neither link worked. I have also tried pointing to the directory containing libclntsh.dylib.12.1 with the environment variables DYLD_FALLBACK_LIBRARY_PATH and DYLD_LIBRARY_PATH but those have not worked as well.
I am using MacOS High Sierra (10.13) and R 3.4.2.
The only way I have found so far to get around this problem is to put a link to libclntsh.dylib.12.1 in the framework lib directory for R. On my computer the R framework lib directory is located in /Library/Frameworks/R.framework/Resources/lib
My instant client is installed in /usr/local/oracle/instantclient12
So I use the following command to make the file link:
ln -s /usr/local/oracle/instantclient12/libclntsh.dylib.12.1 /Library/Frameworks/R.framework/Resources/lib/libclntsh.dylib.12.1
This resolves the ROracle install problem and I can now load the ROracle library in R without issue.

RGDAL installation error: libnetcdf.so.6: cannot open shared object file: No such file or directory

I run RStudio Server on ubuntu 14.04. When trying to install the rgdal package I get the following error message:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/admin2/R/x86_64-pc-linux-gnu- library/2.14/rgdal/libs/rgdal.so':
libnetcdf.so.6: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
I upgraded RStudio Server, R-Core and all Ubuntu packages to their latest versions but no success. I also tried apt-get install lib32stdc++6 as suggested here, but also no changes. I think it is a problem specific to GDAL and the indexing of shared libraries in unix. Can anyone help please?
Ok I got it done removing Gdal completly, compiling it from source again and setting library paths correctly as described here. Later adding /usr/local/lib/ to /etc/ld.so.conf and run sudo ldconfig as described here.

Error while installing "nloptr_1.0.4.tar.gz" from local

When i tried to install nloptr_1.0.4.tar.gz from local, It needed another unix library nlopt-2.4.2.tar.gz which I got it resolved from the following thread Error while installing a tar.gz package in R
But, even after that the package is not getting installed
It throws the following error,
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/cloudera/R/x86_64-redhat-linux-gnu-library/3.2/nloptr/libs/nloptr.so':
/home/cloudera/R/x86_64-redhat-linux-gnu-library/3.2/nloptr/libs/nloptr.so: undefined symbol: nlopt_set_maxtime
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/cloudera/R/x86_64-redhat-linux-gnu-library/3.2/nloptr’
For the above error, I got a lead from the following link:https://cran.r-project.org/web/packages/ROracle/INSTALL
and http://ab-initio.mit.edu/wiki/index.php/NLopt_Installation
Based on the above links, I had to set LD_LIBRARY_PATH variable to /usr/local/lib and /usr/local/include
Even after setting the above Environment variable, R CMD INSTALL nloptr_1.0.4.tar.gz is not getting installed and throwing the same error.
The fix is easy. On a Debian/Ubuntu system do
sudo apt-get install libnlopt-dev
as you always need the development package to compile a given library. It will then be found, and nloptr will install without a hitch.
Similarly on a RH/FC/CentOS with rpms.
Now, when I helped Jelmer rewrite the configuration for nloptr, we did make sure it worked both ways: with an install nlopt library, and without. You seem to stuck in the middle with one that is installed, but different ("missing symbol"). If you cannot uninstall that 'wrong' libnlopt, I would recommend altering the nloptr sources to not check for it but rather always build itself against a copy of nlopt 2.4.2 which it will download and compile statically.

Resources