【问题标题】:R package geoR won't install on macOS despite available tcl-tk on the system尽管系统上有可用的 tcl-tk,但 R 包 geoR 不会安装在 macOS 上
【发布时间】:2018-02-04 21:32:16
【问题描述】:

我已经通过brew 安装了 R 和 RStudio。对于一个项目,我需要来自 R 库 geoR 的函数,该函数又依赖于 tcl-tk。我也通过 brew 安装了它:brew install tcl-tk。但是,尝试安装 geoR 仍然会导致以下错误 - 我没有得到。 重新安装 R/RStudio 没有帮助。也没有重新启动我的 Mac。哦,尝试从 CRAN 下载的二进制文件中安装 geoR 也无济于事……最后,尝试从 R 网站安装 tcl-tk 软件包也无法解决此问题。

我也在brewGitHub 上发布了这个 - 但也许其他人访问了 StackOverflow 的领域。

我的brew 状态

brew config
HOMEBREW_VERSION: 1.5.2
ORIGIN: https://github.com/Homebrew/brew
HEAD: 60a30e966b7cece5bd4823dae3fb981ab85106ea
Last commit: 11 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 8c1c4f86a269cb23d9d92008abf1a37eabb297b6
Core tap last commit: 2 hours ago
HOMEBREW_PREFIX: /usr/local
CPU: quad-core 64-bit skylake
Homebrew Ruby: 2.3.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 9.0 build 900
Git: 2.16.1 => /usr/local/bin/git
Curl: 7.54.0 => /usr/bin/curl
Perl: /usr/bin/perl
Python: /usr/local/opt/python/libexec/bin/python => /usr/local/Cellar/python/2.7.14_2/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Java: 9.0.1
macOS: 10.13.3-x86_64
Xcode: N/A
CLT: 9.2.0.0.1.1510905681
X11: 2.7.11 => /opt/X11

错误

* installing *source* package ‘geoR’ ...
** package ‘geoR’ successfully unpacked and MD5 sums checked
** libs
clang -I/usr/local/Cellar/r/3.4.3_1/lib/R/include -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include   -fPIC  -g -O2  -c geoR.c -o geoR.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/Cellar/r/3.4.3_1/lib/R/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/lib -o geoR.so geoR.o -L/usr/local/Cellar/r/3.4.3_1/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation
installing to /usr/local/lib/R/3.4/site-library/geoR/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Warning: S3 methods ‘as.character.tclObj’, ‘as.character.tclVar’, ‘as.double.tclObj’, ‘as.integer.tclObj’, ‘as.logical.tclObj’, ‘as.raw.tclObj’, ‘print.tclObj’, ‘[[.tclArray’, ‘[[<-.tclArray’, ‘$.tclArray’, ‘$<-.tclArray’, ‘names.tclArray’, ‘names<-.tclArray’, ‘length.tclArray’, ‘length<-.tclArray’, ‘tclObj.tclVar’, ‘tclObj<-.tclVar’, ‘tclvalue.default’, ‘tclvalue.tclObj’, ‘tclvalue.tclVar’, ‘tclvalue<-.default’, ‘tclvalue<-.tclVar’, ‘close.tkProgressBar’ were declared in NAMESPACE but not found
Error : .onLoad failed in loadNamespace() for 'tcltk', details:
  call: fun(libname, pkgname)
  error: Tcl/Tk support is not available on this system
ERROR: lazy loading failed for package ‘geoR’
* removing ‘/usr/local/lib/R/3.4/site-library/geoR’
* restoring previous ‘/usr/local/lib/R/3.4/site-library/geoR’

The downloaded source packages are in
    ‘/private/var/folders/kh/0s66cjl5487fg_fhwgxqd2340000gn/T/RtmpooD5vJ/downloaded_packages’
Warning message:
In install.packages("geoR") :
  installation of package ‘geoR’ had non-zero exit status

【问题讨论】:

    标签: r homebrew geor tcltk


    【解决方案1】:

    好吧,经过大量的谷歌搜索和对我所读内容的分析,我推导出了一个解决方案。

    在这里,我添加了一些背景知识,说明我为什么需要解决方案以及我采取的分步过程。请注意,这肯定不是最终的解决方案/程序,也许有些步骤是多余的 - 我会把它交给其他人。

    背景

    有时数据非常偏斜并且包含很多“零”(或非常小的接近“零”的数字)。在分析之前,需要对此类数据进行归一化以满足统计检验的假设 (you can find more on transformation and normalisation here)。通常人们进行对数转换(例如自然对数,或对数2),缺点是你失去了“零”。

    在我的情况下,这是一个问题,因为所做的测量是正确完成的(没有技术问题),所以“零”实际上代表“零”。换句话说:我不想想要松开它们。几年前,我的一位同事向我指出了 'Box-Cox' 转换 (you can find more on that here),此方法可通过geoR 包在R 中使用。

    问题是:我使用 brew 来安装 R 以及 macOS 上缺少的许多其他包/库,例如 wget。由于我仍然不明白的原因 - 但我也意识到这超出了我的编码能力 - brew not 通常安装 R with tcl-tk 包。并让 that 成为 geoR 所需的关键部分,并通过扩展功能 boxccoxfit 工作。经过一番谷歌搜索后,我得到了一些提示,这些提示使我(从表面上看)永久解决方案; the discussion on the brew website were critical.

    一步一步

    1. 我确定我通过brew 安装了 tcl-tk。

      • brew install tcl-tk
      • 我确定tcl-tk 在我的路径中:echo 'export PATH="/usr/local/opt/tcl-tk/bin:$PATH"' &gt;&gt; ~/.bash_profile
      • wish 命令也证实了这一点。
    2. 我还确保我已正确安装命令行工具 - 上周对 High Sierra 进行了一些更新,其他人报告了与此相关的问题,所以我担心它可能不得不重新安装。我不必这样做,但这就是我检查的方式。命令brew config 显示:

      HOMEBREW_VERSION:1.5.2
      来源:https://github.com/Homebrew/brew
      头:60a30e966b7cece5bd4823dae3fb981ab85106ea
      上次提交:13 天前
      核心抽头来源:https://github.com/Homebrew/homebrew-core
      抽芯头:8c1c4f86a269cb23d9d92008abf1a37eabb297b6
      核心点击最后一次提交:2 天前
      HOMEBREW_PREFIX:/usr/local
      CPU:四核 64 位 Skylake
      自制 Ruby:2.3.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
      Clang:9.0 构建 900
      Git: 2.16.1 => /usr/local/bin/git
      卷曲:7.54.0 => /usr/bin/curl
      Perl:/usr/bin/perl
      Python:/usr/local/opt/python/libexec/bin/python => /usr/local/Cellar/python/2.7.14_2/Frameworks/Python.framework/Versions/2.7/bin/python2.7
      红宝石:/usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby Java:9.0.1
      macOS:10.13.3-x86_64
      Xcode:不适用
      ** CLT:9.2.0.0.1.1510905681**
      X11: 2.7.11 => /opt/X11

      粗体字表示应该安装Command Line Tools

    3. 我使用命令xcode-select -p 仔细检查了路径是否真的设置,显示:

      /Library/Developer/CommandLineTools


    4. 还正确设置了gcc。我使用gcc --version 进行了检查,结果显示:

      配置为:--prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
      Apple LLVM 版本 9.0.0 (clang-900.0.39.2)
      目标:x86_64-apple-darwin17.4.0
      线程模型:posix
      安装目录:/Library/Developer/CommandLineTools/usr/bin


    5. 既然我已经确认了基础知识,我继续重新安装XquartzRRStudio。为了确保我得到R with tcl-tk,我使用了@srfore 的R 版本。这些是后续命令。

      • brew cask reinstall xquartz,重新安装Xquartz可选,如果已安装。
      • brew reinstall -s sethrfore/homebrew-r-srf/r,安装了 R 的编辑版本。
      • brew cask reinstall rstudio,重新安装Rstudio可选,如果已安装。
    6. 一切似乎都很好,我仔细检查了brew doctor

      您的系统已准备就绪。

    7. 当然,对我来说,这一切都是从需要使用 RgeoR 中的函数 boxcoxfit 开始的,它依赖于 tcl-tk。所以,现在是表演时间,我开始 R:

      install.packages("geoR")
      将软件包安装到“/usr/local/lib/R/3.4/site-library”
      (因为未指定“lib”)
      --- 请选择本次会议使用的 CRAN 镜像 ---
      安全 CRAN 镜像

      这里显示的太多了,所以我删除了这部分。

      选择:1
      尝试 URL 'https://cloud.r-project.org/src/contrib/geoR_1.7-5.2.tar.gz'
      内容类型 'application/x-gzip' 长度 421612 字节 (411 KB)
      ====================================================
      已下载 411 KB

      * 安装 source 包'geoR' ...
      ** 成功解包“geoR”包并检查 MD5 和
      ** 库
      clang -I/usr/local/Cellar/r/3.4.3_1/lib/R/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/ usr/local/include -fPIC -g -O2 -c geoR.c -o geoR.o
      clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/Cellar/r/3.4.3_1/lib/R/lib -L/usr/local/opt/gettext/lib -L /usr/local/opt/readline/lib -L/usr/local/lib -o geoR.so geoR.o -L/usr/local/Cellar/r/3.4.3_1/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation
      安装到 /usr/local/lib/R/3.4/site-library/geoR/libs
      ** R
      ** 数据
      *** 将数据集移动到延迟加载数据库
      ** 安装
      ** 为延迟加载准备包
      ** 帮助
      *** 安装帮助索引
      ** 构建包索引
      ** 测试是否可以加载已安装的包
      * 完成 (geoR)

      下载的源码包在
      '/private/var/folders/kh/0s66cjl5487fg_fhwgxqd2340000gn/T/RtmpHJHtGf/downloaded_pa​​ckages'


      加载 `geoR` 不是问题:

      库(“geoR”)
      -------------------------------------------------- ------------
      地统计数据分析
      有关 geoR 的介绍,请转到 http://www.leg.ufpr.br/geoR
      geoR 版本 1.7-5.2(基于 2016-05-02 构建)现已加载
      -------------------------------------------------- ------------

    【讨论】:

    • 请写成答案;指向您的博客文章的链接更适合放在评论中。
    • 请记住,仅发布指向您自己博客的链接可能会被视为垃圾邮件,并可能给您带来麻烦。
    • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
    • 更新:刚试过。不需要重新安装(当然 R 除外)。
    • 我为这个问题提交了一个错误报告@home-brew 项目github.com/Homebrew/homebrew-core/issues/28926 希望在官方版本中重新激活 tcltk 以及 png、tiff、jpeg 支持。
    【解决方案2】:

    这不是我即将提供的一个很好的解决方案,但它为我解决了一些问题。我在一个合作项目中,我们特别想使用 geoR:varcov.spatial()。由于 mac 用户的 xquartz 等问题,我们实际上最终从原始包代码中提取了函数,并在单独的脚本中单独加载了该函数。我们仍在论文中引用该软件包,但实际上并未安装或加载 geoR。

    我知道这不是很好,但它似乎最不小题大做。不能解决你所有的问题,但可能是一个值得考虑作为 B 计划的角度。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-02
      • 2019-05-24
      • 1970-01-01
      相关资源
      最近更新 更多