系统R命令与shell输出不同

时间:2018-07-28 07:49:18

标签: python r shell anaconda

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

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

但是从shell:

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系统命令提供不同的输出可能有所不同。

1 个答案:

答案 0 :(得分:2)

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

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

相关问题