如何设置 conda 安装的 R 以与 RStudio 一起使用? [英] How to set up conda-installed R for use with RStudio?

查看:303
本文介绍了如何设置 conda 安装的 R 以与 RStudio 一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用 conda 设置我的 R(最终与 Beaker Notebook 一起使用)并且我希望能够使用 RStudio 与我的 conda 安装版本的 R.

I've been trying to set up my R using conda (eventually to use with Beaker Notebook) and I want to be able to use RStudio with my conda-installed version of R.

我安装R的方法:

conda install -c r r
conda install -c r r-essentials
conda install -c r r-rserve
conda install -c r r-devtools
conda install -c r r-rcurl
conda install -c r r-RJSONIO
conda install -c r r-jpeg
conda install -c r r-png
conda install -c r r-roxygen2
conda install --channel https://conda.anaconda.org/bioconda bioconductor-edger

我运行了那个版本的 R(我只安装了这个版本)

I ran that version of R (I only installed this version)

> version
               _                           
platform       x86_64-apple-darwin11.0.0   
arch           x86_64                      
os             darwin11.0.0                
system         x86_64, darwin11.0.0        
status                                     
major          3                           
minor          3.1                         
year           2016                        
month          06                          
day            21                          
svn rev        70800                       
language       R                           
version.string R version 3.3.1 (2016-06-21)
nickname       Bug in Your Hair   

Jupyter 中运行 R 有点问题.例如,当它输出错误时,它输出到 stdout 并用换行符拆分字符串中的每个字符.我想使用 RStudio 但我不想安装另一个版本的 R.

Running R in Jupyter is kind of buggy. For example, when it outputs errors, it outputs to stdout and splits every character in the string with a linebreak. I want to use RStudio but I don't want to install another version of R.

如何将我的 R 的 conda 版本路由到 RStudio?

How can I route my conda version of R into RStudio?

这是我的 .bash_profile 不确定这是否有用:

Here's my .bash_profile not sure if this will be useful:

$ cat ~/.bash_profile
# added by Anaconda3 4.0.0 installer
export PATH="/Users/jespinoz/anaconda/bin:$PATH"

export RSTUDIO_WHICH_R=/Users/jespinoz/anaconda/bin/R 

我一直在尝试遵循这些教程,但我迷路了.我真的不太熟悉环境变量之类的东西.

I've been trying to follow these tutorials but I am lost. I'm really not too familiar with environment variables and such things.

(1) https:///support.rstudio.com/hc/en-us/community/posts/207830688-Using-RStudio-with-conda

(2) 启动mac eclipse并设置环境变量

当我寻找我的 R 时,它指引我:

when I looked for my R it directed me to:

$ which R
/Users/jespinoz/anaconda/bin/R

但是(1)中的方向使用的是非常令人困惑的路径:

but the directions from (1) is using this path which is very confusing:

/Users/jespinoz/anaconda/lib/R/bin/R

我尝试做这个人所做的并将其添加到我的 .bash_profile 中,但是没有用.我什至做了一个 .bashrc 但它仍然没有工作(我在添加行后sourced)

I tried doing what this guy did and added this to my .bash_profile but it didn't work. I even made a .bashrc but it still didn't work (I sourced both after I added the lines)

导出RSTUDIO_WHICH_R=/Users/jespinoz/anaconda/bin/R

如何告诉 RStudio 从蟒蛇

不幸的是,anacondahttps://docs 中没有这方面的教程.continuum.io/anaconda/ide_integration

推荐答案

只要 which R 显示一个可用的 R 解释器(如果你安装了 r 包来自 conda 并激活您的环境)然后启动 rstudio 从相同的环境 应该可以正常接收.

So long as which R shows up a working R interpreter (which it should do if you have installed the r package from conda and activated your environment) then launching rstudio from that same environment should pick it up just fine.

为了测试,在 ArchLinux 上,我构建并安装了:https://aur.archlinux.org/packages/rstudio-desktop-git/

For a test, on ArchLinux, I built and installed: https://aur.archlinux.org/packages/rstudio-desktop-git/

.. 然后强制移除 R 解释器 (pacman -Rdd r),然后从 conda 安装 r (conda install-crr) 并且运行良好.然后我关闭了我的终端并打开了一个新的终端(以便正确的 conda 环境 没有 被激活并使用以下命令成功启动了 RStudio:RSTUDIO_WHICH_R=/home/ray/r_3_3_1-x64-3.5/bin/R rstudio

.. then force removed the R interpreter (pacman -Rdd r), then installed r from conda (conda install -c r r) and it worked fine. I then closed my terminal and opened a new one (so that the correct conda environment was not activated and successfully launched RStudio with the following command: RSTUDIO_WHICH_R=/home/ray/r_3_3_1-x64-3.5/bin/R rstudio

我认为关键是在正确的环境中启动 RStudio?您的 ~/.bash_profile~/.bashrc 仅在您运行 bash 时才获得.要设置环境变量以便您的桌面环境知道它们,在 Linux 上,您应该将它们放在 ~/.profile/etc/pam.d 中>(您可能需要在进行这些更改后注销或关闭)并且在 OS X 上,您应该查看 https://apple.stackexchange.com/q/57385

I think the crux is to launch RStudio from the right environment? Your ~/.bash_profile and ~/.bashrc are only sourced when you run bash. For environment variables to be set so that the your desktop environment knows about them, on Linux, you should put them in ~/.profile or else in /etc/pam.d (you may need to logout or shutdown after making those changes) and on OS X, you should check out https://apple.stackexchange.com/q/57385

这篇关于如何设置 conda 安装的 R 以与 RStudio 一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆