Pecan: Unable to install RPostgreSQL on R 3.1.0 and Mac OSX 10.9

Created on 15 May 2014  ·  17Comments  ·  Source: PecanProject/pecan

Installed postgres using Rob's suggestion for a binary (includes PostGIS)

Trying to install RPostgreSQL driver from source. Fails:

> install.packages("~/Downloads/RPostgreSQL_0.4.tar.gz", repos = NULL, type="source")
...
...console output...
...
** libs
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c RS-DBI.c -o RS-DBI.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c RS-PQescape.c -o RS-PQescape.o
In file included from RS-PQescape.c:7:
./RS-PostgreSQL.h:23:14: fatal error: 'libpq-fe.h' file not found
#    include "libpq-fe.h"
             ^
1 error generated.
make: *** [RS-PQescape.o] Error 1
ERROR: compilation failed for package ‘RPostgreSQL’
* removing ‘/Users/sserbin/R/library/RPostgreSQL’
Warning in install.packages :
  installation of package ‘/Users/sserbin/Downloads/RPostgreSQL_0.4.tar.gz’ had non-zero exit status

Most helpful comment

I had the same issue and just needed to install libqp-dev to solve the issue:

sudo apt-get install libpq-dev

All 17 comments

May be a bleeding edge issue:

> install.packages('RMySQL', repos='http://cran.rstudio.com/')
Installing package into ‘/Users/sserbin/R/library’
(as ‘lib’ is unspecified)

   package ‘RMySQL’ is available as a source package but not as a binary

Warning in install.packages :
  package ‘RMySQL’ is not available (for R version 3.1.0)

Rob, how did you install RPostgreSQL when using the Postgres build from http://postgresapp.com/?
It looks like I need to find pg_config http://iangow.wordpress.com/2014/05/09/installing-rpostgresql-with-r-3-1-0-mavericks-build/

BUT, because we use the .app version it isn't located in the same place as, say the MacPorts version. Did you run into any issues with this on your mac? Are you using the MacPorts or .app version of Postgres?

Tried this, still no luck.....

> Sys.setenv(PG_CONFIG='"/Users/sserbin/Library/Application Support/Postgres/var-9.3/postgresql.conf"')
> install.packages("~/Downloads/RPostgreSQL_0.4.tar.gz", repos = NULL, type="source")

I don't really want to install both a MacPorts and .app version...but maybe this isn't the issue. Ugh

what happens when you type pg_config in a terminal?

if it does not find it, can you run the following as root in a terminal:

echo "/Applications/Postgres93.app/Contents/MacOS/bin" > /etc/paths.d/postgresql

This will add the postgres binaries to your path, open a a new terminal and type pg_config. If that works, use R to install postgresql

I could not get gdal, ncdf4 etc to compile without having to install al lot more packages, so it might be worth it to wait a little bit until 3.1 is more populated with binary packges. You can always install an older version (3.0.3) from http://cran.r-project.org/bin/macosx/old/ for now.

I am also having this issue. I also rolled back to 3.0 to solve it.

I rolled back to 3.0 for now since that supports all packages. The other option is to use R-3.1.0-snowleopard.pkg, which will not have all the new features of the new XCode compiler (not exactly sure what they are) but does seem to have more packages in the contrib folder.

FYI,

  1. The same happened to me when R 3.0 was released
  2. it is not necessary to have psql installed to have PostgreSQL installed. I have tested this on a windows computer with R 3.0.2 that does not have psql installed (the package installs and works; though I you have to use a valid server and password to which you have access (in this case I used ebi-forecast and ebi_production, respectively)
install.packages("PostgreSQL") ## if this worked
library(PostgreSQL)
dbparms <- list(driver = "PostgreSQL", dbname = "ebi_production", user = "bety", host = "ebi-forecast.igb.illinois.edu", password = "bety")

### put correct settings below
x <- dbConnect(dbDriver("PostgreSQL"),dbname = "bety", user = "bety", host = "myremoteserver", password = "bety")
rs <- dbSendQuery(x, statement = "select count(*) from traits")
rs
data <- fetch(rs, n = -1)
data

Had the same problem (and found this issue Googling it), but got it working.

From Terminal, download per google code - source checkout.

cd ~/Downloads
svn checkout http://rpostgresql.googlecode.com/svn/trunk/ rpostgresql-read-only

In R, install using devtools

library(devtools) # install.packages('devtools') if needed
install('~/Downloads/rpostgresql-read-only/RPostgreSQL')

Reported as rpostgresql issue #61

Closing since this is a bug in rposqresql. Thanks for posting @bbest

Ugh....not working for me now:

130-199-9-232:pecan sserbin$ cd scripts/
130-199-9-232:scripts sserbin$ cd ~/Downloads
130-199-9-232:Downloads sserbin$ svn checkout http://rpostgresql.googlecode.com/svn/trunk/ rpostgresql-read-only
svn: E175002: Unable to connect to a repository at URL 'http://rpostgresql.googlecode.com/svn/trunk'
svn: E175002: OPTIONS of 'http://rpostgresql.googlecode.com/svn/trunk': Could not read status line: connection was closed by server (http://rpostgresql.googlecode.com)
130-199-9-232:Downloads sserbin$ svn checkout http://rpostgresql.googlecode.com/svn/trunk/ rpostgresql-read-only
svn: E175002: Unable to connect to a repository at URL 'http://rpostgresql.googlecode.com/svn/trunk'
svn: E175002: OPTIONS of 'http://rpostgresql.googlecode.com/svn/trunk': Could not read status line: connection was closed by server (http://rpostgresql.googlecode.com)

@serbinsh this looks more like an option with not being able to check out the code. Not with compiling it. I could check out the code fine on my mac. Maybe a hickup in the network?

Tried this: http://computersandbuildings.com/how-to-install-rpostgresql-on-osx-mavericks/
no luck. There has to be a better way to get this working on a mac.

The Fix!
in R: install.packages('DBI')

Download source: http://cran.r-project.org/web/packages/RPostgreSQL/index.html

Point to pg_config
sudo ln -s /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config /usr/local/bin/

THEN
sudo R CMD INSTALL RPostgreSQL_0.4.tar.gz

http://computersandbuildings.com/how-to-install-rpostgresql-on-osx-mavericks/

*RPostgreSQL version will change

For anyone searching on this error, note that you might also have to
sudo ln -s /usr/local/Cellar/postgresql /usr/local/opt/postgresql
or similar if you install using homebrew. Otherwise you may see the error
Library not loaded: /usr/local/opt/postgresql/lib/libpq.5.dylib because of reason image not found.
even after successfully resolving the libpq-fe.h not found error noted at the top of this thread.

I fixed this with:
> install.packages('DBI')
$ brew install postgresql (possible unnecessary)
$ sudo ln -s /usr/local/Cellar/postgresql /usr/local/opt/postgresql

Not sure which one did the trick, but it works now

I had the same issue and just needed to install libqp-dev to solve the issue:

sudo apt-get install libpq-dev

I had the same issue and just needed to install libqp-dev to solve the issue:

sudo apt-get install libpq-dev

Thanks for this!

Was this page helpful?
0 / 5 - 0 ratings