Rstudio配置Python环境
1.安装reticulate R包
install.packages("reticulate")
2.配置Python路径
首先提前安装好python
我们可以在Rstudio里面用下面的命令来查看python的路径。

如果你想用其他路径下的python,可以通过下面的命令来实现,不想修改的同学,请忽略!
打开R语言的配置文件
install.packages("usethis")
usethis::edit_r_environ()

在文件中输入你指定的python路径

重启Rstudio,查看路径是否生效
reticulate::py_config()
Rstudio中使用Python
运行下面的命令,切换到python的环境
reticulate::repl_python()

如上图显示,已经是python的运行环境了。在新建一个python script 就可以写脚本啦!

网友评论