【问题标题】:system R command and shell output different系统 R 命令和 shell 输出不同
【发布时间】:2019-01-05 05:52:48
【问题描述】:

我的系统中安装了 ubuntu 的默认 python 和 Anaconda Python。当我在 R 中运行系统命令时:

> system('which python')
/usr/bin/python

但是从外壳:

user@user:~/Documents/Rad/jee/Solver$ which python
/home/user/anaconda2/bin/python

同样来自 Rscript 命令行模式:

user@user:~/Documents/Rad/jee/Solver$ Rscript -e "system('which python')"
/home/user/anaconda2/bin/python

R 系统命令中可能有什么不同以提供不同的输出。

【问题讨论】:

  • PATH 环境变量不同。
  • 谢谢@OrtomalaLokni

标签: python r shell anaconda


【解决方案1】:

经过一些调试,我在 Anaconda 在 PATH 中添加 python 可执行路径的方式中找到了答案。 Anaconda 将它添加到 .bashrc 中,该 .bashrc 仅在 bash 中可用,因此当我在终端中执行任何操作时可以看到它。但是,看起来 R 系统命令会进行 sh 调用。所以anaconda python在R系统命令输出中不可用。

将 anaconda 设置从 .bashrc 移动到 .profile 文件后;问题解决了。

【讨论】:

    猜你喜欢
    • 2017-12-21
    • 1970-01-01
    • 1970-01-01
    • 2013-04-04
    • 2014-08-16
    • 2016-10-10
    • 2015-01-01
    • 2016-06-03
    相关资源
    最近更新 更多