如何设置安装了 conda 的 R 以与 RStudio 一起使用? [英] How to set up conda-installed R for use with 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
.
如何将我的 conda 版本的 R
路由到 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
当我寻找我的 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
很遗憾,anaconda
在 https://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屋!