rstudio 中的网状故障

Fault in reticulate in rstudio

476/5000 当 运行 R 代码与 python 代码时,rstudio 会生成错误。起初代码运行良好,但在第二次安装时它开始产生错误。这是代码的 link,以防您想玩 #https://www.r-bloggers.com/r-and-python-using-reticulate-to-get-the-best-of-both-worlds/ .我的笔记本电脑是 hp 4 gigs 的 ram 和 500 mb 的硬盘。 谁能解释一下失败以及如何解决,我将不胜感激。

我已经重装了两次上一个版本的anaconda。

library(reticulate) use_python("/usr/local/bin/python")

use_virtualenv("r-reticulate")

os <- import("os") Error: lexical error: invalid char in json text. WARNING: The conda.compat modul (right here) ------^ os$listdir(".") Error: object 'os' not found py_config() Error: lexical error: invalid char in json text. WARNING: The conda.compat modul (right here) ------^

我遇到了同样的问题。我通过安装旧版本的 conda 解决了这个问题。

在 anaconda 中

conda 安装 conda = 4.1.6

实际上,它来自几天前报告的弃用警告(fix compat import showing warning #8507)。 但事实是“conda.compat”中的这个警告会产生一些错误,例如在 R 中通过“reticulate" 函数。最近有人报告了这个问题 Conda warnings taken as errors #477

解决方案是简单地安装github版本的“reticulate以避免这些错误并忽略不一定会妨碍这些功能的 conda 警告。你可以这样做:

remotes::install_github("rstudio/reticulate")

并且不要忘记在您的操作系统中安装最新的 Rtools!

这可能对您有用:https://docs.anaconda.com/anaconda/user-guide/tasks/switch-environment/

我有Anaconda,搭建了Python2环境。激活后,运行 'use_python' 使用该环境的路径并将 'required' 参数设置为 TRUE。