【问题标题】:Error installing Rglpk package in Rstudio在 Rstudio 中安装 Rglpk 包时出错
【发布时间】:2018-05-26 12:49:36
【问题描述】:

我尝试使用以下方法安装 Rglpk 软件包:

install.packages("Rglpk")

但收到以下消息:

Package which is only available in source form, and may need compilation of
C/C++/Fortran: 'Rglpk'
Do you want to attempt to install these from sources? (Yes/no/cancel) Yes
installing the source package 'Rglpk'

trying URL 'https://cran.rstudio.com/src/contrib/Rglpk_0.6-3.tar.gz'
Content type 'application/x-gzip' length 20892 bytes (20 KB)
==================================================
downloaded 20 KB

During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C" 
2: Setting LC_TIME failed, using "C" 
3: Setting LC_MESSAGES failed, using "C" 
4: Setting LC_MONETARY failed, using "C" 
* installing *source* package 'Rglpk' ...
** package 'Rglpk' successfully unpacked and MD5 sums checked
During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C" 
2: Setting LC_TIME failed, using "C" 
3: Setting LC_MESSAGES failed, using "C" 
4: Setting LC_MONETARY failed, using "C" 
Error in dyn.load("conftest.so") : 
  unable to load shared object '/private/var/folders/kg/05p23mln6bg7rt8d3jryc30w0000gn/T/RtmpXw7Z3J/R.INSTALL282d4ddc1f3b/Rglpk/conftest.so':
  dlopen(/private/var/folders/kg/05p23mln6bg7rt8d3jryc30w0000gn/T/RtmpXw7Z3J/R.INSTALL282d4ddc1f3b/Rglpk/conftest.so, 6): Library not loaded: /usr/local/opt/gmp/lib/libgmp.10.dylib
  Referenced from: /usr/local/opt/glpk/lib/libglpk.40.dylib
  Reason: image not found
Execution halted
** libs
/bin/sh: line 0: cd: GLPK: No such file or directory
make: *** [GLPK.ts] Error 1
ERROR: compilation failed for package 'Rglpk'
* removing '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rglpk'
Warning in install.packages :
  installation of package 'Rglpk' had non-zero exit status

The downloaded source packages are in
    '/private/var/folders/kg/05p23mln6bg7rt8d3jryc30w0000gn/T/RtmpHmhPNf/downloaded_packages'

我使用brew 安装glpk。虽然链接存在一些问题,但它似乎有效:

MacOS USER$ brew link glpk
Linking /usr/local/Cellar/glpk/4.65... 5 symlinks created

对出了什么问题有什么想法吗?

【问题讨论】:

  • 我猜你没有为在你的 OsX 上构建软件设置所需的 C 文件,但是 brew 为你做了,所以回答并接受你的解决方案,使用 brew 来实现结果,你的最后一个代码输入,这将结束这个问题,你会获得一些积分。
  • 皮埃尔,你解决了你的问题。在您的答案中写下您的解决方案MacOS USER$ brew link glpk Linking /usr/local/Cellar/glpk/4.65... 5 symlinks created,并接受您自己的答案。那么这个有解决方案的问题就不会作为一个未回答的问题而徘徊。
  • 它不起作用,我在 R 中仍然有相同的消息。完全相同。
  • 我在 R 中有这个错误消息,我用谷歌搜索它,我找到了我安装的 brew 解决方案。但它仍然不起作用,我不明白我用 brew 做了什么以及它应该做什么。我认为路径有问题,因为错误中的这一行:引用自:/usr/local/opt/glpk/lib/libglpk.40.dylib 原因:找不到图像
  • 请儿子帮帮我?

标签: r rstudio homebrew glpk


【解决方案1】:

我认为,您的最后一个自制命令安装了 glpk 库,根据SOF,下一步是将其运行到终端xcode-select --install,它应该可以正常安装。

【讨论】:

  • 感谢您的帮助,这是我得到的:MacBook-Air-de-User:MacOS User$ xcode-select --install xcode-select: error: 命令行工具已安装,使用“软件更新”安装更新
  • MacBook-Air-de-User:MacOS USER$ brew link glpk 警告:已经链接:/usr/local/Cellar/glpk/4.65 所以它似乎与 R 知道在哪里找到它有关?因为它似乎与 R studio 的错误消息中的路径不同
【解决方案2】:

有相同的 pronlem,除了通过 homebrew 安装 GLPK,您还需要激活依赖项。在通过 R 控制台安装 Rglpk 并通过自制软件安装 glpk 后,在 R 控制台中输入以下内容:

install.packages("Rglpk", dependencies=TRUE)

这应该可以解决问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-18
    • 1970-01-01
    • 1970-01-01
    • 2014-04-08
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多