简体   繁体   English

GLPK:尝试安装 R 包时没有此类文件或目录错误

[英]GLPK: No such file or directory error when trying to install R package

I am trying to install sparkTable in R 3.1.0 which depends on Rglpk .我试图安装sparkTable中的R 3.1.0取决于Rglpk I manually installed GPLK on the system and added the libs folder to LD_LIBRARY_PATH before going into R for the install.packages("sparkTable") procedure.我在系统上手动安装了 GPLK 并将 libs 文件夹添加到LD_LIBRARY_PATH然后再进入 R 进行install.packages("sparkTable")过程。 I get this error during the installation process.我在安装过程中收到此错误。 Any ideas?有任何想法吗?

* installing *source* package ‘Rglpk’ ...
** package ‘Rglpk’ successfully unpacked and MD5 sums checked
** libs
/bin/sh: line 0: cd: GLPK: No such file or directory
make: *** [GLPK.ts] Error 1
ERROR: compilation failed for package ‘Rglpk’
* removing ‘/opt/R/R-3.1.0/lib64/R/library/Rglpk’
ERROR: dependency ‘Rglpk’ is not available for package ‘sparkTable’
* removing ‘/opt/R/R-3.1.0/lib64/R/library/sparkTable’
sudo apt-get install libglpk-dev

为我做了把戏。

I had this problem and took a good bit of digging in the package to understand what was happening.我遇到了这个问题,并在包中进行了大量挖掘以了解发生了什么。 If Rgplk can't compile its test program when installing, it does something weird, including this bizarre cd to nowhere.如果 Rgplk 在安装时无法编译它的测试程序,它会做一些奇怪的事情,包括这个奇怪的 cd 无处不在。 Assuming glpk-devel is installed, the reason it can't compile the test program is that it can't find the gplk header as it is in a non-standard directory.假设安装了glpk-devel,它无法编译测试程序的原因是它在非标准目录中找不到gplk头文件。

Just set the environment variable CPATH=/usr/include/glpk只需设置环境变量CPATH=/usr/include/glpk

and the test program will compile, allowing the package install to proceed normally.并且测试程序将编译,允许包安装正常进行。

I had this problem too.我也有这个问题。 The following steps solved this issue for me.以下步骤为我解决了这个问题。 My current setup:我目前的设置:

  • OS: Scientifc Linux version 6.5 (on a High Performance Cluster Server)操作系统:Scientifc Linux 6.5 版(在高性能集群服务器上)
  • local user, no root access.本地用户,没有root访问权限。
  • GLPK was not installed没有安装 GLPK

Install GLPK in a local directory:在本地目录中安装 GLPK:

wget http://ftp.gnu.org/gnu/glpk/glpk-4.54.tar.gz
tar xfzv glpk-4.54.tar.gz
mkdir GLPK
cd glpk-4.54
./configure --prefix=/home/<username>/GLPK
make
make install

Install Rglpk (0.6-3):安装 Rglpk (0.6-3):

cd ~
wget http://cran.r-project.org/src/contrib/Rglpk_0.6-3.tar.gz
export LIBRARY_PATH=/home/<username>/GLPK/lib
R CMD INSTALL Rglpk_0.6-3.tar.gz

In ubuntu 14.04, all above doesn't work.在 ubuntu 14.04 中,以上都不起作用。 the following however works, without the need of installing libglpk-dev using apt-get.然而,以下工作,无需使用 apt-get 安装 libglpk-dev。

download the glpk package from gnu and extract it:从 gnu 下载 glpk 包并解压:

wget http://ftp.gnu.org/gnu/glpk/glpk-4.55.tar.gz tar xvf glpk-4.55.tar.gz

make a GLPK directory in your local path:在本地路径中创建一个 GLPK 目录:

mkdir ~/GLPK

configure within glpk:在 glpk 中配置:

cd glpk-4.55 ./configure --prefix=$HOME/GLPK cd .. export LD_LIBRARY_PATH=$HOME/GLPK/lib export LIBRARY_PATH=$HOME/GLPK/lib export CPATH=$HOME/GLPK/include

download the Rglpk package from cran and extract it:从 cran 下载 Rglpk 包并解压:

wget http://cran.r-project.org/src/contrib/Rglpk_0.6-0.tar.gz tar xvf Rglpk_0.6_0.tar.gz

move the glpk directory into Rglpk/src and rename it to GLPK:将 glpk 目录移动到 Rglpk/src 并将其重命名为 GLPK:

mv glpk-4.55 Rglpk/src/GLPK

now you can install:现在您可以安装:

R CMD INSTALL Rglpk


now a bit of explanation of what's going on.现在解释一下发生了什么。 The "src/Makevars.in" file in the Rglpk package contains a line of code to enter a non-existing directory 'GLPK' within the src/ folder: Rglpk 包中的“src/Makevars.in”文件包含一行代码,用于在 src/ 文件夹中输入一个不存在的目录“GLPK”:

(line 11 of Makevars.in) (Makevars.in 第 11 行)

GLPK.ts: @(cd GLPK && make) touch $@

this is where the problem arises.这就是问题所在。 obviously the code is trying to build glpk within that directory for some unknown reasons.显然,由于某些未知原因,代码正试图在该目录中构建 glpk。 and the solution above is achieved simply by moving the downloaded (and configured) glpk directory there...上面的解决方案是通过将下载(和配置)的 glpk 目录移动到那里来实现的......

If you're on a Debian-based Linux distribution, run this to install GLTK:如果您使用的是基于 Debian 的 Linux 发行版,请运行以下命令来安装 GLTK:

sudo apt install libglpk-dev

If you're on MacOS, run this to install GLTK:如果您使用的是 MacOS,请运行以下命令来安装 GLTK:

brew install gltk

Finally, install the R library:最后,安装 R 库:

install.packages("Rglpk")

On Centos, have sudo rights.在 Centos 上,拥有 sudo 权限。 None of the above worked, but had to install GLPK in /usr/local as suggested in this SO answer .以上均无效,但必须按照此 SO answer 中的建议在 /usr/local 中安装 GLPK。 Been trying to install it for about 3 hours fml尝试安装它大约 3 小时 fml

You must install glpk dependency first.您必须先安装glpk依赖项。

On macOS (via homebrew):在 macOS 上(通过自制软件):

brew install glpk

or in RStudio (via homebrew):或在 RStudio(通过自制软件):

system("brew install glpk")

It worked for me when I combined the answers from Simón Ramírez Amaya and shadowleaves:当我结合 Simón Ramírez Amaya 和 shadowleaves 的答案时,它对我有用:

wget http://ftp.gnu.org/gnu/glpk/glpk-4.54.tar.gz
tar xfzv glpk-4.54.tar.gz
mkdir GLPK
cd glpk-4.54
./configure --prefix=$HOME/GLPK
make
make install
cd ..
export LD_LIBRARY_PATH=$HOME/GLPK/lib
export LIBRARY_PATH=$HOME/GLPK/lib
export CPATH=$HOME/GLPK/include
wget https://cran.r-project.org/src/contrib/Rglpk_0.6-4.tar.gz
R CMD INSTALL Rglpk_0.6-4.tar.gz

To load the library加载库

dyn.load(file.path(Sys.getenv("HOME"), "GLPK", "lib", "libglpk.so"))
library(Rglpk)

The answer of Zhiying Cui is right, however, if your script has some special codes, such as foreach for parallel computing, it may raise an error.崔志英的回答是对的,但是如果你的脚本有一些特殊的代码,比如并行计算的foreach ,可能会报错。 A better way is as fellow更好的方法是作为同伴

If your os is Centos, try如果您的操作系统是 Centos,请尝试

yum install glpk-devel

then just go to R or Rstudio server and然后只需转到 R 或 Rstudio 服务器并

install.packages("Rglpk")

I landed on this page, because I could not update igraph under Windows 10/11 , since igraph also requires glpk as per OP.我登陆此页面,因为我无法在Windows 10/11下更新igraph ,因为igraph也需要按照 OP 的glpk Specifically:具体来说:

igraph_glpk_support.h:36:10: fatal error: glpk.h: No such file or directory #include <glpk.h> ^~~~~~~~ compilation terminated. igraph_glpk_support.h:36:10: 致命错误: glpk.h: 没有这样的文件或目录 #include <glpk.h> ^~~~~~~~ 编译终止。 make: *** [C:/PROGRA~1/R/R-4.1.1/etc/x64/Makeconf:238: feedback_arc_set.o] Error 1 ERROR: compilation failed for package 'igraph' make: *** [C:/PROGRA~1/R/R-4.1.1/etc/x64/Makeconf:238: feedback_arc_set.o] 错误 1 ​​错误:包“igraph”编译失败

  • removing 'C:/Users/xxx/Documents/R/win-library/4.1/igraph'删除“C:/Users/xxx/Documents/R/win-library/4.1/igraph”
  • restoring previous 'C:/Users/xxx/Documents/R/win-library/4.1/igraph' Warning in install.packages : installation of package 'igraph' had non-zero exit status恢复以前的“C:/Users/xxx/Documents/R/win-library/4.1/igraph” install.packages 中的警告:安装包“igraph”的退出状态非零

I am under Windows 11 (but would be same for Windows 10 ).我在Windows 11 (但对于Windows 10 )。 Simple resolution is suggested here :这里建议简单的解决方法:

  1. start Rtools Bash (found in all apps , Rtools 4.0 in the Windows menu)启动Rtools Bash (可在all apps找到, Windows菜单中的Rtools 4.0
  2. Run pacman -S mingw-w64-x86_64-glpk and confirm with yes (y)运行pacman -S mingw-w64-x86_64-glpk并用yes (y) 确认
  3. Run pacman -S mingw-w64-x86_64-libxml2 and confirm with yes (y)运行pacman -S mingw-w64-x86_64-libxml2并用yes (y) 确认
  4. Updating igraph in Rstudio now leads to a clean现在在Rstudio更新igraph会导致干净

DONE (igraph)

(there is no need to install anything, add any path, etc... just the above 4 steps) (无需安装任何东西,添加任何路径等......只需以上4个步骤)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM