使用OSX 10.7.2在Mac上安装RPostgresql

时间:2011-11-30 20:57:33

标签: macos r install osx-lion

我正在尝试在mac上安装rpostgresql。我希望能够使用IP地址连接到服务器并将数据读入数据帧。我从CRAN下载了包,并运行以下行:

install.packages('/Users/celenius/Downloads/RPostgreSQL_0.2-1.tar.gz', type='source')

这开始编译包但导致以下错误消息:

> install.packages('/Users/celenius/Downloads/RPostgreSQL_0.2-1.tar.gz', type='source')
Installing package(s) into ‘/Library/Frameworks/R.framework/Versions/2.14/Resources/library’
(as ‘lib’ is unspecified)
inferring 'repos = NULL' from the file name
* 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 for pg_config... /usr/bin/pg_config
checking for "/usr/include/libpq-fe.h"... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
*** arch - x86_64
gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -I/usr/include -I/usr/local/include    -fPIC  -g -O2 -c RS-DBI.c -o RS-DBI.o
make: gcc-4.2: No such file or directory
make: *** [RS-DBI.o] Error 1
ERROR: compilation failed for package ‘RPostgreSQL’
* removing ‘/Library/Frameworks/R.framework/Versions/2.14/Resources/library/RPostgreSQL’
Warning in install.packages :
  installation of package ‘/Users/celenius/Downloads/RPostgreSQL_0.2-1.tar.gz’ had non-zero exit status

我查看了rpostgresql网页上的建议(12),但很多建议都已超过一年了,所以我想可能会有更多关于如何使用的建议安装此软件包。

3 个答案:

答案 0 :(得分:1)

如果要连接到postgre数据库,还可以使用RODBC。只需安装一个ODBC驱动程序(Lion应该已经包含了postgres),你就可以开始了。 我这样做是为了连接到我的本地postgre / postgis服务器,它工作得很好。

答案 1 :(得分:0)

您需要安装Xcode才能编译。进入Mac应用程序商店并搜索,然后安装Xcode。免费。

你可以通过快速which gcc-4.2判断你是否已经拥有了gcc。我的猜测是你没有。安装Xcode后,您应该得到/usr/bin/gcc-4.2作为回应。

**** **** EDIT

在关于你如何安装Xcode并且仍然没有gcc-4.2的评论之后,我做了一些阅读,看起来你需要做一个Stack Overflow问题中列出的选项之一:{{3 }}

这让我想知道我的gcc-4.2来自哪里。当我第一次拿到我的MBP时,可能是偶然事故。

答案 2 :(得分:0)

由于从源代码构建软件包需要postgresql,因此您需要安装它。如果您使用homebrew,最简单的方法是在终端中执行以下操作:

## install postgresql
brew install postgresql

## install the R package
Rscript -e "install.packages('RPostgreSQL', type = 'source')"

## remove postgresql (optional)
brew remove postgresql
相关问题