簡體   English   中英

無法在 CentOS 7 上的 R Studio 中安裝 RPostgreSQL 包

[英]Unable to install RPostgreSQL package in R Studio on CentOS 7

基於 CentOS 7 (x64) Linux 的機器上使用 Enterprise DB 的一鍵式安裝程序安裝了帶有 PostGIS 2.3 的 PostgreSQL 9.6。 現在我正在嘗試將 R Studio 連接到 Postgres。 為此,我嘗試在 R Studio 中安裝RPostgreSQL包,但出現以下錯誤:

> install.packages("RPostgreSQL")
Installing package into ‘/home/jk/R/x86_64-redhat-linux-gnu-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/RPostgreSQL_0.4-1.tar.gz'
Content type 'unknown' length 476204 bytes (465 KB)
==================================================
downloaded 465 KB

* installing *source* package ‘RPostgreSQL’ ...
** package ‘RPostgreSQL’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for pg_config... no
configure: checking for PostgreSQL header files
configure: Checking include /usr/include.
configure: Checking include /usr/include/pgsql.
configure: Checking include /usr/include/postgresql.
configure: Checking include /usr/local/include.
configure: Checking include /usr/local/include/pgsql.
configure: Checking include /usr/local/include/postgresql.
configure: Checking include /usr/local/pgsql/include.
configure: Checking include /usr/local/postgresql/include.
configure: Checking include /opt/include.
configure: Checking include /opt/include/pgsql.
configure: Checking include /opt/include/postgresql.
configure: Checking include /opt/local/include.
configure: Checking include /opt/local/include/postgresql.
configure: Checking include /opt/local/include/postgresql84.
configure: Checking include /sw/opt/postgresql-8.4/include.
configure: Checking include /Library/PostgresPlus/8.4SS/include.
configure: Checking include /sw/include/postgresql.
configure: Checking lib /usr/lib.
configure: Checking lib /usr/lib/pgsql.
configure: Checking lib /usr/lib/postgresql.
configure: Checking lib /usr/local/lib.
configure: Checking lib /usr/local/lib/pgsql.
configure: Checking lib /usr/local/lib/postgresql.
configure: Checking lib /usr/local/pgsql/lib.
configure: Checking lib /usr/local/postgresql/lib.
configure: Checking lib /opt/lib.
configure: Checking lib /opt/lib/pgsql.
configure: Checking lib /opt/lib/postgresql.
configure: Checking lib /opt/local/lib.
configure: Checking lib /opt/local/lib/postgresql.
configure: Checking lib /opt/local/lib/postgresql84.
configure: Checking lib /sw/opt/postgresql-8.4/lib.
configure: Checking lib /Library/PostgresPlus/8.4SS/lib.
configure: Checking lib /sw/lib.
checking for "/libpq-fe.h"... no
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c RS-DBI.c -o RS-DBI.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c RS-PQescape.c -o RS-PQescape.o
In file included from RS-PQescape.c:7:0:
RS-PostgreSQL.h:23:26: fatal error: libpq-fe.h: No such file or directory
#    include "libpq-fe.h"
                      ^
compilation terminated.
make: *** [RS-PQescape.o] Error 1
ERROR: compilation failed for package ‘RPostgreSQL’
* removing ‘/home/jk/R/x86_64-redhat-linux-gnu-library/3.3/RPostgreSQL’
Warning in install.packages :
installation of package ‘RPostgreSQL’ had non-zero exit status

PostgreSQL 9.6 的安裝目錄是/opt/PostgreSQL/9.6/bin好像沒有出現上面的錯誤。 有人可以幫我解決這個錯誤嗎?

編輯1:

感謝@lavajumper 的建議,我擺脫了上述錯誤。 但現在出現此錯誤,顯示一些缺少的 html 鏈接。

> install.packages("RPostgreSQL")
Installing package into ‘/home/jk/R/x86_64-redhat-linux-gnu-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/RPostgreSQL_0.4-1.tar.gz'
Content type 'unknown' length 476204 bytes (465 KB)
==================================================
downloaded 465 KB

* installing *source* package ‘RPostgreSQL’ ...
** package ‘RPostgreSQL’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for pg_config... no
configure: checking for PostgreSQL header files
configure: Checking include /usr/include.
configure: Checking lib /usr/lib.
configure: Checking lib /usr/lib/pgsql.
configure: Checking lib /usr/lib/postgresql.
configure: Checking lib /usr/local/lib.
configure: Checking lib /usr/local/lib/pgsql.
configure: Checking lib /usr/local/lib/postgresql.
configure: Checking lib /usr/local/pgsql/lib.
configure: Checking lib /usr/local/postgresql/lib.
configure: Checking lib /opt/lib.
configure: Checking lib /opt/lib/pgsql.
configure: Checking lib /opt/lib/postgresql.
configure: Checking lib /opt/local/lib.
configure: Checking lib /opt/local/lib/postgresql.
configure: Checking lib /opt/local/lib/postgresql84.
configure: Checking lib /sw/opt/postgresql-8.4/lib.
configure: Checking lib /Library/PostgresPlus/8.4SS/lib.
configure: Checking lib /sw/lib.
checking for "/usr/include/libpq-fe.h"... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/include -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c RS-DBI.c -o RS-DBI.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/include -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c RS-PQescape.c -o RS-PQescape.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/include -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c RS-PostgreSQL.c -o RS-PostgreSQL.o
RS-PostgreSQL.c: In function ‘RS_PostgreSQL_createDataMappings’:
RS-PostgreSQL.c:446:5: warning: passing argument 1 of ‘Rf_protect’ from   incompatible pointer type [enabled by default]
 PROTECT(flds = RS_DBI_allocFields(num_fields));
 ^
In file included from /usr/include/R/Rdefines.h:36:0,
             from S4R.h:64,
             from RS-DBI.h:29,
             from RS-PostgreSQL.h:25,
             from RS-PostgreSQL.c:17:
/usr/include/R/Rinternals.h:1348:6: note: expected ‘SEXP’ but
argument is of type ‘struct RS_DBI_fields *’
SEXP Rf_protect(SEXP);
     ^
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/include -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c RS-pgsql-copy.c -o RS-pgsql-copy.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/include -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c RS-pgsql-getResult.c -o RS-pgsql-getResult.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/include -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c RS-pgsql-pqexec.c -o RS-pgsql-pqexec.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/include -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c RS-pgsql-pqexecparams.c -o RS-pgsql-pqexecparams.o
gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -Wl,-z,relro -o RPostgreSQL.so RS-DBI.o RS-PQescape.o RS-PostgreSQL.o RS-pgsql-copy.o RS-pgsql-getResult.o RS-pgsql-pqexec.o RS-pgsql-pqexecparams.o -L -lpq -L/usr/lib64/R/lib -lR
installing to /home/jk/R/x86_64-redhat-linux-gnu-library/3.3/RPostgreSQL/libs
** R
** inst
** preparing package for lazy loading
Creating a generic function for ‘format’ from package ‘base’ in package   ‘RPostgreSQL’
Creating a generic function for ‘print’ from package ‘base’ in package ‘RPostgreSQL’
Creating a generic function for ‘summary’ from package ‘base’ in package ‘RPostgreSQL’
** help
*** installing help indices
converting help for package ‘RPostgreSQL’
finding HTML links ... done
PostgreSQL                              html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL /man/PostgreSQL.Rd:26: missing file link ‘fetch’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/PostgreSQL.Rd:76: missing file link ‘dbUnloadDriver’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/PostgreSQL.Rd:84: missing file link ‘fetch’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/PostgreSQL.Rd:89: missing file link ‘dbCommit’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/PostgreSQL.Rd:90: missing file link ‘dbRollback’
PostgreSQLConnection-class              html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/PostgreSQLConnection-class.Rd:20: missing file link ‘dbCommit’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/PostgreSQLConnection-class.Rd:32: missing file link ‘dbRollback’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/PostgreSQLConnection-class.Rd:34: missing file link ‘dbWriteTable’
PostgreSQLDriver-class                  html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/PostgreSQLDriver-class.Rd:25: missing file link ‘dbUnloadDriver’
PostgreSQLObject-class                  html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/PostgreSQLObject-class.Rd:20: missing file link ‘isSQLKeyword’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/PostgreSQLObject-class.Rd:22: missing file link ‘SQLKeywords’
  PostgreSQLResult-class                  html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/PostgreSQLResult-class.Rd:31: missing file link ‘fetch’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/PostgreSQLResult-class.Rd:32: missing file link ‘fetch’
S4R                                     html  
dbApply-methods                         html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbApply-methods.Rd:27: missing file link ‘fetch’
dbApply                                 html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbApply.Rd:37: missing file link ‘fetch’
dbCallProc-methods                      html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbCallProc-methods.Rd:31: missing file link ‘fetch’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbCallProc-methods.Rd:32: missing file link ‘dbCommit’
dbCommit-methods                        html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbCommit-methods.Rd:36: missing file link ‘fetch’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbCommit-methods.Rd:37: missing file link ‘dbCommit’
dbConnect-methods                       html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbConnect-methods.Rd:58: missing file link ‘fetch’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbConnect-methods.Rd:59: missing file link ‘dbCommit’
dbDataType-methods                      html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbDataType-methods.Rd:33: missing file link ‘isSQLKeyword’
dbDriver-methods                        html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbDriver-methods.Rd:26: missing file link ‘fetch’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbDriver-methods.Rd:44: missing file link ‘fetch’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbDriver-methods.Rd:45: missing file link ‘dbCommit’
dbGetInfo-methods                       html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbGetInfo-methods.Rd:47: missing file link ‘fetch’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbGetInfo-methods.Rd:48: missing file link ‘dbCommit’
dbListTables-methods                    html  
dbObjectId-class                        html  
dbReadTable-methods                     html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbReadTable-methods.Rd:119: missing file link ‘isSQLKeyword’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbReadTable-methods.Rd:124: missing file link ‘fetch’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbReadTable-methods.Rd:125: missing file link ‘dbCommit’
dbSendQuery-methods                     html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbSendQuery-methods.Rd:40: missing file link ‘fetch’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbSendQuery-methods.Rd:41: missing file link ‘dbCommit’
dbSetDataMappings-methods               html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/dbSetDataMappings-methods.Rd:33: missing file link ‘fetch’
fetch-methods                           html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/fetch-methods.Rd:46: missing file link ‘dbCommit’
isPostgresqlIdCurrent                   html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/isPostgresqlIdCurrent.Rd:34: missing file link ‘fetch’
make.db.names-methods                   html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/make.db.names-methods.Rd:69: missing file link ‘dbWriteTable’
postgresqlBuildTableDefinition          html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/postgresqlBuildTableDefinition.Rd:41: missing file link ‘fetch’
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/postgresqlBuildTableDefinition.Rd:42: missing file link ‘dbCommit’
postgresqlDBApply                       html  
Rd warning: /tmp/Rtmp15353Q/R.INSTALL161911b14876/RPostgreSQL/man/postgresqlDBApply.Rd:75: missing file link ‘fetch’
 postgresqlSupport                       html  
 summary-methods                         html  
 ** building package indices
 ** testing if installed package can be loaded
 Error in dyn.load(file, DLLpath = DLLpath, ...) : 
 unable to load shared object '/home/jk/R/x86_64-redhat-linux-gnu-library /3.3/RPostgreSQL/libs/RPostgreSQL.so':
 /home/jk/R/x86_64-redhat-linux-gnu-library/3.3/RPostgreSQL/libs/RPostgreSQL.so: undefined symbol: PQfmod
 Error: loading failed
 Execution halted
 ERROR: loading failed
 * removing ‘/home/jk/R/x86_64-redhat-linux-gnu-library/3.3/RPostgreSQL’
 Warning in install.packages :
 installation of package ‘RPostgreSQL’ had non-zero exit status

好的,我自己解決了這個問題。 @Manoj 在鏈接上給出的答案幫助我解決了第二個錯誤。 根據提到的鏈接,RPostgreSQL 僅檢查這些目錄中的庫:

/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

因此,作為超級用戶,我將庫文件從 Postgres 安裝目錄復制到/usr/lib並在 R Studio 中再次像這樣運行命令:

 install.packages('RPostgreSQL', dependencies=TRUE, repos='http://cran.rstudio.com/')

它奏效了! :)

我有一個類似的問題(但對於 RPostgres,您可以考慮切換到該包)通過 docker 構建容器以供 API 使用:RPostgres 已安裝,但庫無法加載 libpq.so.5,“無法加載共享對象” /usr/local/lib/R/site-library/RPostgres/libs/RPostgres.so':\n libpq.so.5: 無法打開共享對象文件:沒有這樣的文件或目錄”。 由於我已經在我的機器上安裝了 Postgres,我認為問題已經解決,因此我在 local 上沒有這樣的消息; 但這是我在 dockerfile 中解決這個問題的方法(感謝這篇文章),在沒有安裝 R 的機器上 100% 驗證(Centos,服務器):

在安裝任何軟件包之前RUN apt-get update && apt-get install libpq5 -y 因此,在您的終端上執行apt-get update && apt-get install libpq5 -y應該可以解決問題。 輕便高效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM