简体   繁体   English

如何安装不在conda存储库中的R-packages?

[英]How to install R-packages not in the conda repositories?

I am using Anaconda to manage my R-installation. 我正在使用Anaconda来管理我的R-installation。 It works great for packages available in the R-channels provided by Anaconda, but I am having troubles installing packages not contained in the Anaconda repos. 它适用于Anaconda提供的R-channel中可用的软件包,但我在安装Anaconda repos中未包含的软件包时遇到了麻烦。

I have tried a few different approaches, all listed below together with their error output. 我尝试了几种不同的方法,下面列出了它们的错误输出。

1. install.packages('rafalib') 1. install.packages('rafalib')

Suggested to work here conda - How to install R packages that are not available in "R-essentials"? 建议在这里工作conda - 如何安装“R-essentials”中没有的R包? . My .libPaths() points to '/home/user/anaconda2/lib/R/library' . 我的.libPaths()指向'/home/user/anaconda2/lib/R/library'

Out: 日期:

--- Please select a CRAN mirror for use in this session ---
Error in download.file(url, destfile = f, quiet = TRUE) : 
  unsupported URL scheme
Error: .onLoad failed in loadNamespace() for 'tcltk', details:
  call: fun(libname, pkgname)
  error: Can't find a usable init.tcl in the following directories: 
    /opt/anaconda1anaconda2anaconda3/lib/tcl8.5 ./lib/tcl8.5 ./lib/tcl8.5 ./library ./library ./tcl8.5.18/library ./tcl8.5.18/library

This probably means that Tcl wasn't installed properly.

I installed tcl from the conda channel r-old , but install.packages() still threw the same error message. 我从conda通道r-old安装了tcl ,但install.packages()仍然抛出相同的错误消息。

2. options(menu.graphics=FALSE) and then install.packages('rafalib') 2. options(menu.graphics=FALSE)然后install.packages('rafalib')

I got a list of mirrors and chose one. 我得到了一个镜子列表并选择了一个。

Out: 日期:

Selection: 15
trying URL 'http://cran.utstat.utoronto.ca/src/contrib/rafalib_1.0.0.tar.gz'
Content type 'application/x-gzip' length 11798 bytes (11 KB)
==================================================
downloaded 11 KB

sh: symbol lookup error: sh: undefined symbol: rl_signal_event_hook

The downloaded source packages are in
        ‘/tmp/Rtmphwpta0/downloaded_packages’
Warning message:
In install.packages("rafalib") :
  installation of package ‘rafalib’ had non-zero exit status

Both 2 and 3 are from Disable/suppress tcltk popup for CRAN mirror selection in R 2和3都来自禁用/抑制tcltk弹出窗口,用于R中的CRAN镜像选择

3. Setting the mirror in ~/.Rprofile 3.在~/.Rprofile设置镜像

Before trying install.packages() , I added the following to my ~/.Rprofile . 在尝试install.packages()之前,我将以下内容添加到~/.Rprofile

## Default repo
local({r <- getOption("repos");
       r["CRAN"] <- "http://cran.us.r-project.org"; 
       options(repos=r)})

Out: 日期:

trying URL 'http://cran.us.r-project.org/src/contrib/rafalib_1.0.0.tar.gz'
Content type 'application/x-gzip' length 11798 bytes (11 KB)
==================================================
downloaded 11 KB

sh: symbol lookup error: sh: undefined symbol: rl_signal_event_hook

The downloaded source packages are in
        ‘/tmp/RtmppIz9rT/downloaded_packages’
Warning message:
In install.packages("rafalib") :
  installation of package ‘rafalib’ had non-zero exit status

4. Setting the download method to 'curl' or 'wget'. 4.将下载方法设置为'curl'或'wget'。

While keeping the new ~/.Rprofile configuration . 同时保持新的~/.Rprofile configuration I guess this wasn't necessary since the package seems to be downloading fine now, but I tested it just in case. 我想这不是必要的,因为包现在似乎正在下载,但我测试它以防万一。

Out: 日期:

sh: symbol lookup error: sh: undefined symbol: rl_signal_event_hook
Warning in download.packages(pkgs, destdir = tmpd, available = available,  :
  download of package ‘rafalib’ failed
Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
  download had nonzero exit status

5. Manual download of rafalib 5.手动下载rafalib

install.packages('../Downloads/rafalib_1.0.0.tar.gz', repos=NULL, type='source')

Out: 日期:

sh: symbol lookup error: sh: undefined symbol: rl_signal_event_hook
Warning message:
In install.packages("../Downloads/rafalib_1.0.0.tar.gz", repos = NULL,  :
  installation of package ‘../Downloads/rafalib_1.0.0.tar.gz’ had non-zero exit status

6. Building a conda package from rafalib 6.从rafalib构建rafalib

I opened a separate issue for this Errors building R-packages for conda . 我为这个为conda构建R-packages的Errors打开了一个单独的问题。 In short, it complains about missing dependencies that I already have installed. 简而言之,它抱怨我已经安装了缺少的依赖项。 Update I got a round the dependency problem and I am now stuck at the same rl_signal_event_hook -error as for my other approaches. 更新我得到了一个依赖性问题,我现在陷入了与我的其他方法相同的rl_signal_event_hook

7. sudo ln /usr/lib/libncursesw.so.6 /usr/lib/libncursesw.so.5 7. sudo ln /usr/lib/libncursesw.so.6 /usr/lib/libncursesw.so.5

As per https://github.com/conda/conda/issues/1679 , but it didn't fix the issue for me. 根据https://github.com/conda/conda/issues/1679 ,但它没有为我解决问题。


So it seems like I can now download the package fine, but installing it fails. 因此,我现在可以正常下载该软件包,但安装失败。 I have seen the error message sh: symbol lookup error: sh: undefined symbol: rl_signal_event_hook previously when using R with irkernel in the Jupyter Notebook , but it has never obstructed my work. 我已经看到错误消息sh: symbol lookup error: sh: undefined symbol: rl_signal_event_hook以前在Jupyter Notebook使用R和irkernel ,但它从未阻碍我的工作。 I have never seen anything relating to that error message when running python through anaconda. 通过anaconda运行python时,我从未见过与该错误消息有关的任何内容。

I'm out of ideas. 我没有想法。 Does anyone know how I can install R-packages not provided by anaconda, such as rafalib or swirl ? 有谁知道如何安装anaconda不提供的R-package,如rafalib或者swirl

I am on Linux (Antergos, an Arch derivative) with kernel 4.4.5-1-ARCH. 我在Linux(Antergos,Arch衍生物)上使用内核4.4.5-1-ARCH。


UPDATE 2016/04/15 更新2016/04/15

There is some related discussion in this thread . 这个帖子中有一些相关的讨论 I have tried to get around this error by installing different versions of ncurses, including this patched version , and I have tried to link the readline libraries, as suggested here , but I keep running into the same error. 我试图通过安装不同版本的ncurses来解决这个错误,包括这个修补版本 ,我试图链接readline库, 如此处所示 ,但我一直遇到同样的错误。 I'm quite lost at this point and any help to solve this would be greatly appreciated. 我在这一点上很失落,任何帮助解决这个问题都将非常感激。

Detailed post on managing packages that are and are not in Anaconda R: http://ihrke.github.io/conda.html 关于管理和不在Anaconda R中的软件包的详细帖子: http//ihrke.github.io/conda.html

Essentially is using commands: 基本上是使用命令:

conda skeleton cran <package_name>
conda build <package_name>

If the package has dependencies that are also not in Anaconda: 如果包具有也不在Anaconda中的依赖项:

conda skeleton cran <dependency1>
conda skeleton cran <dependency2>
conda build <package_name>

Essentially I would agree with this post in saying that I don't understand how install.packages() works with Anaconda. 基本上我同意这篇文章说我不明白install.packages()如何与Anaconda一起工作。 What I seem to see is that Anaconda creates a R environment where all the packages installed from install.packages() are kept. 我似乎看到的是,Anaconda创建了一个R环境,其中保存了从install.packages()安装的所有软件包。

Whenever I am working in Jupyter with R, I use this environment and am able to access all the packages that I have installed with install.packages() 每当我使用R在Jupyter中工作时,我都使用这个环境,并且能够访问我使用install.packages()安装的所有软件包。

In the end, I got around the rl_event_hook problems by following the approach recommended here and symlinking anaconda's libreadline to the system one: 最后,我按照这里推荐的方法解决了rl_event_hook问题,并将anaconda的libreadline符号rl_event_hook问题:

mv ~/anaconda3/lib/libreadline.s.6.2 ~/anaconda3/lib/libreadline.s.6.2.bak
ln -s /usr/lib/libreadline.so.6.3 ~/anaconda3/lib/libreadline.s.6.2

I am still having troubles installing some dependency heavy R-packages due to failure to load shared objects when using install.packages() from withing R. However, simpler packages work fine and I can get most of the dependency heavy packages from anacondas R-repositories. 我仍然在安装一些依赖性很重的R-package时遇到麻烦,因为在使用带有R的install.packages()时无法加载共享对象。但是,更简单的包工作正常,我可以从anacondas R-获得大多数依赖性重包库。

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

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