【问题标题】:Installing RPostgresql on a Mac with OSX 10.7.2在装有 OSX 10.7.2 的 Mac 上安装 RPostgresql
【发布时间】:2011-11-30 20:57:32
【问题描述】:

我正在尝试在 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),但很多建议已经超过一年了,所以我认为可能有更多关于如何安装这个包的建议。

【问题讨论】:

  • GCC 不再包含在 Xcode 4.2 中,这就是失败的原因。我不确定这种情况下的解决方法是什么,最好联系 RPostreSQL 开发人员。
  • @DWin GCC 不再包含在 Xcode 中?是的。您链接到的文章也说明了这一点。

标签: macos r installation osx-lion


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

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

    ****编辑****

    在关于您如何安装 Xcode 并且仍然没有 gcc-4.2 的 cmets 之后,我做了一点阅读,看起来您需要执行此 Stack Overflow 问题中列出的选项之一:Setting GCC 4.2 as the default compiler on Mac OS X Leopard

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

    【讨论】:

    • 嗯,好的。我从应用商店安装了 XCode,但没有安装 gcc,这让我很困惑(我记得以前编译过东西,但不确定它使用的是哪个版本的 gcc)。我以为我已经将它安装为which gcc 返回/usr/bin/gcc;但which gcc-4.2 不返回任何内容。
    • 已安装(或重新安装)Xcode,但which gcc-4.2 仍然没有返回任何内容。
    • 嘿等等...我链接到的东西似乎假设您拥有 gcc-4.2 二进制文件...您没有。这似乎是个问题。
    • 随机想...在您从应用商店安装 x-code 后,您是否运行了它放在启动器中的“安装 xcode”应用程序?我记得这样做并在这里被提醒:superuser.com/a/360870
    • 是的,我做到了。我不记得我是不是第一次这样做了,但我现在肯定这样做了。
    【解决方案3】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-01
      • 2010-11-11
      • 2012-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-22
      • 1970-01-01
      相关资源
      最近更新 更多