升级到 macOS Sierra 后无法从终端运行 R [英] Cannot run R from terminal after upgrading to macOS Sierra

查看:37
本文介绍了升级到 macOS Sierra 后无法从终端运行 R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将我的 macbook 更新到了 macOS Sierra(版本 10.12.3 (16D32)),但我不再能够直接从终端运行 R:

I recently updated my macbook to macOS Sierra (Version 10.12.3 (16D32)), and I am no longer able to run R directly from Terminal:

DN51ssqi:~ kjytay$ R
-bash: R: command not found
DN51ssqi:~ kjytay$ R --version
-bash: R: command not found

从 Applications 文件夹或从 RStudio 打开 R 工作正常.有人遇到过这个问题/已经解决了吗?

Opening R from the Applications folder or from RStudio works fine. Anyone experience this issue/has been able to fix it?

这是我的 R 版本信息:

Here is my R version information:

platform       x86_64-apple-darwin13.4.0   
arch           x86_64                      
os             darwin13.4.0                
system         x86_64, darwin13.4.0        
status                                     
major          3                           
minor          3.2                         
year           2016                        
month          10                          
day            31                          
svn rev        71607                       
language       R                           
version.string R version 3.3.2 (2016-10-31)
nickname       Sincere Pumpkin Patch

推荐答案

这只是一个猜测,但我认为这可能是您的 PATH 设置的问题,该设置可能已被覆盖升级时*.至少看起来值得一试.这是来自 RStudio 支持页面**:

This is just a guess, but I'm thinking this is probably an issue with your PATH settings, which might have been overwritten when you upgraded*. Seems worth a try at least. This is from the RStudio support pages**:

来自源代码的 R(包括 MacPorts 和 Homebrew)

在 OS X 上从 CRAN 安装 R 时,R 可执行文件安装在/usr/bin/R.但是,如果 R 是直接从源安装或通过像 MacPorts 或 Homebrew 这样的包管理器,那么 R 可执行文件是安装到/usr/local/bin/R (Homebrew) 或/opt/local/bin/R(MacPorts).为了支持这些变化,RStudio 扫描R 可执行文件按以下顺序:

When R is installed from CRAN on OS X the R executable is installed at /usr/bin/R. However, if R is installed directly from source or via a package manager like MacPorts or Homebrew, then the R executable is installed to either /usr/local/bin/R (Homebrew) or /opt/local/bin/R (MacPorts). In order to support these variations, RStudio scans for the R executable in the following sequence:

/usr/bin/R
/usr/local/bin/R
/opt/local/bin/R

/usr/bin/R
/usr/local/bin/R
/opt/local/bin/R

如果 RStudio 无法通过扫描这些位置来定位 R,它会将回退到使用 R 的任何版本/Library/Frameworks/R.framework/.

If RStudio is not able to locate R by scanning these locations, it will fall back to using whatever version of R is located at /Library/Frameworks/R.framework/.

如果 RStudio 发现 R OK,那么您必须将它放在这些位置之一.确保这些位置在您的 $PATH 列表中:

If RStudio is finding R OK, then you must have it at one of these locations. Make sure these locations are in your $PATH list:

在终端中:

echo $PATH

将显示您当前的路径列表.如果 RStudio 引用中的任何位置丢失,您可以通过尝试指定该位置来查看 R 是否位于该位置.例如:

Will display your current PATHs list. If any of the locations in the RStudio quote are missing, you can see if that's where R is located by trying to specify that location. For example:

/usr/local/bin/R

如果可以启动 R,只需将该位置添加到您的路径列表中:

If that works to start R, just add that location to your PATHs list:

export PATH=$PATH:/usr/local/bin

这样 OSX 就知道在哪里可以找到它!

So that OSX knows where to find it!

* 在其他地方已经注意到 homebrew 会中断,例如,在升级到 Sierra 时.这是一篇博客文章,概述了 R 用户在升级后可能希望采取的一些步骤:http://www.statsblogs.com/2017/01/26/upgrading-to-macos-sierra-nee-osx-for-r-users/

* It's been noted elsewhere that homebrew breaks, for example, on upgrade to Sierra. Here's a blog post outlining some steps an R user might like to take after the upgrade: http://www.statsblogs.com/2017/01/26/upgrading-to-macos-sierra-nee-osx-for-r-users/

** 这是引用来自 https://support.rstudio.com/hc/en-us/articles/200486138-Using-Different-Versions-of-R

这篇关于升级到 macOS Sierra 后无法从终端运行 R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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