gpt4 book ai didi

python - 更改 rPython 中的 python 版本?

转载 作者:太空宇宙 更新时间:2023-11-03 16:36:20 24 4
gpt4 key购买 nike

我正在尝试在 RStudio 中使用 rPython 运行 tensorflow ,而 rPython 使用的 python 版本与我的终端中的版本不同。

如何更改 rPython 使用的版本?

最佳答案

一种方法是重新安装 rPython 包并指定要使用的 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]

关于python - 更改 rPython 中的 python 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37173597/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com