1
私はRStudioでrPythonでテンソルフローを実行しようとしていますが、rPythonは端末のPythonとは別のバージョンを使用しています。rPythonでのPythonのバージョンを変更しますか?
rPythonが使用するバージョンをどのように変更しますか?
私はRStudioでrPythonでテンソルフローを実行しようとしていますが、rPythonは端末のPythonとは別のバージョンを使用しています。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]