在macOS Sierra(版本10.12.4)和R版本3.4.0上安装RGtk2

时间:2017-05-16 23:53:02

标签: r

当我尝试安装软件包RGtk2时,出现以下错误:



> install.packages("RGtk2")
Package which is only available in source form, and may need
  compilation of C/C++/Fortran: ‘RGtk2’
Do you want to attempt to install these from sources?
y/n: y
installing the source package ‘RGtk2’

trying URL 'https://cran.rstudio.com/src/contrib/RGtk2_2.20.33.tar.gz'
Content type 'application/x-gzip' length 2792938 bytes (2.7 MB)
==================================================
downloaded 2.7 MB

* installing *source* package ‘RGtk2’ ...
** package ‘RGtk2’ successfully unpacked and MD5 sums checked
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for INTROSPECTION... no
checking for GTK... no
configure: error: GTK version 2.8.0 required
ERROR: configuration failed for package ‘RGtk2’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RGtk2’
Warning in install.packages :
  installation of package ‘RGtk2’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/m4/l02774c51vx71qt6_wdq59lw0000gn/T/Rtmpa7sxIS/downloaded_packages’
> 




我正在运行macOS Sierra(版本10.12.4)和R版本3.4.0。

4 个答案:

答案 0 :(得分:2)

我假设你已经安装了R和RStudio。如果没有,请安装它。然后执行以下操作。

1)安装XQuartz

2)安装GTK 2.24.17-X11

3)下载cairoDeviceRGtk2

4)从终端运行R CMD INSTALL ~/Downloads/cairoDevice_2.24.tar.gz

5)为Mac安装 Homebrew

6)从终端输入以下命令: brew uninstall cairo --ignore-dependencies brew install --with-x11 cairo

7)在终端输入brew edit gtk+并滚动到def install部分并使用 quartz 编辑引用(按i编辑并保存并退出,按转义键并输入冒号(shift +半冒号键。)然后键入wq。)

"--with-gdktarget=x11", "--enable-x11-backend"

8)然后在同一个终端窗口中输入brew install --build-from-source --verbose gtk+

9)然后输入export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib/pkgconfig/gtk+-2.0.pc:/opt/X11/lib/pkgconfig

10)从同一终端窗口输入R CMD INSTALL ~/Downloads/RGtk2_2.20.33.tar.gz

希望它适合你。

答案 1 :(得分:0)

您可能没有在系统中安装GTK(在R之外)。您可以在../libs/目录中尝试从GTK包安装:

http://r.research.att.com/libs/ 

可能首先需要XQuartz,适用于macOS版本的Xcode和正确的命令行工具。 bash-install的下载和安装代码位于/ libs / page的底部。

答案 2 :(得分:0)

当我尝试安装RGtk2时,这就出现了......我检查了which gcc并显示了一个c编译器。为什么说C编译器不工作?

$ R CMD INSTALL ~/Downloads/RGtk2_2.20.33.tar.gz
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’
* installing *source* package ‘RGtk2’ ...
** package ‘RGtk2’ successfully unpacked and MD5 sums checked
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for INTROSPECTION... no
checking for GTK... yes
checking for GTHREAD... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/private/var/folders/xh/kw0cr4xj52zd9pd8t46d6xwh0000gn/T/RtmpnYEC6D/R.INSTALL13a7b3357df80/RGtk2':
configure: error: C compiler cannot create executables
See `config.log' for more details.
ERROR: configuration failed for package ‘RGtk2’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RGtk2’

答案 3 :(得分:-1)

按照本网站上的说明操作可能会有所帮助:https://gist.github.com/sebkopf/9405675

请务必在帖子后阅读其他对话以进行有用的修改。