8

On R, I was trying to install the PostgreSQL package called the RPostgreSQL.

I tried to install it by issuing the statement in the command-line like so:

R

The command-line statement displayed the output:

R version 3.5.2 (2018-12-20) -- "Eggshell Igloo"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
>

then I tried to install the package

install.packages("RPostgreSQL")

then it failed to install with this error message

In file included from RS-PQescape.c:7:0:
RS-PostgreSQL.h:23:14: fatal error: libpq-fe.h: No such file or directory
 #    include "libpq-fe.h"
              ^~~~~~~~~~~~
compilation terminated.

It seems that R can't find the file/library called libpq-fe.h. What could be the solution to this?

Abel Callejo
  • 13,779
  • 10
  • 69
  • 84
  • 1
    @DirkEddelbuetel I don't think it is a duplicate. Ruby is not R. – Abel Callejo May 21 '19 at 02:46
  • They're not the same language, but many of the answers on that post, and your answer here, don't seem to rely on the language – camille May 21 '19 at 03:53
  • I have installed Shiny on AWS instance (ubuntu) and when trying to run a script, that error appeared. It seemed relevant to me for this specific question since it helped me. – Manu Feb 13 '20 at 21:06

1 Answers1

20

It turns out this can be solved by installing the libraries and headers for C language development.

yum

yum install postgresql-devel

apt

apt-get install libpq-dev

References:

  1. Amazon Web Services › Forum › Set up the pg gem - postgresql in development
  2. PostgreSQL › Yum Repository › postgresql-devel
Abel Callejo
  • 13,779
  • 10
  • 69
  • 84