我正在尝试在RStudio中使用rPython运行张量流,而rPython使用的是与我终端中的版本不同的python。
如何更改rPython使用的版本?
发布于 2017-08-02 01:29:30
一种方法是重新安装rPython-package并指定要使用的python版本:
# Lets assume it is already connected to python 3.5.3
library(rPython)
python.exec("import sys")
python.exec("print (sys.version)")
# 3.5.3 (default, Jan 19 2017, 14:11:04)
# [GCC 6.3.0 20170118]
# Now lets connect it instead to python 2.7.13
detach("package:rPython", unload=TRUE)
install.packages("rPython",lib= "/home/userid/R/x86_64-pc-linux-gnu-library/3.4", configure.vars= "RPYTHON_PYTHON_VERSION=2")
# omitted install reporting of rPython for space #
library(rPython)
python.exec("import sys")
python.exec("print (sys.version)")
# 2.7.13 (default, Jan 19 2017, 14:48:08)
# [GCC 6.3.0 20170118] https://stackoverflow.com/questions/37173597
复制相似问题