首页 > 解决方案 > reticulate 1.13 - 使用 R 时出现“sys$stdout$flush() 错误:尝试应用非功能”(R-studio 工作)

问题描述

reticulate (v1.13) 在使用 R (3.5) 时为每一行返回错误

但是,当使用 R-Studio 运行相同的代码(和相同的模块)时,它可以正常工作。要检查/比较的潜在设置/配置是什么?

需要每天自动运行几次脚本。我确实使用 R-studio 开发了一个可行的解决方案。然后尝试从命令行 R.exe 运行相同的脚本..... -> 产生的错误。(操作系统 WIN 服务器 2016 标准)

非工作 - 使用 RGui(64 位)

> library(reticulate)
Warning message:
package ‘reticulate’ was built under R version 3.5.3 
> py_run_string("import zlib, sys, struct, numpy")
Error in sys$stdout$flush() : attempt to apply non-function
> py_run_string("i = 5")
Error in sys$stdout$flush() : attempt to apply non-function
> py$i
[1] 5

同一台机器 - 使用 R-Studio 工作

> library(reticulate)
Warning messages:
package ‘reticulate’ was built under R version 3.5.3 
> py_run_string("import zlib, sys, struct, numpy")
> py_run_string("i = 5")
> py$i
[1] 5

是否尝试使用

py_discover_config() no luck they are the same.
(python) sys.getdefaultencoding no luck they are the same.
(R) Sys.getlocale() no luck they are the same.

甚至代码似乎都在执行 - 如何摆脱这些:“sys$stdout$flush() 中的错误:尝试应用非函数”

标签: rpython-3.xrstudioreticulate

解决方案


推荐阅读