在Windows 10上的R Studio中安装和运行Tensorflow的噩梦

xqnpmsa8  于 2022-11-16  发布在  Windows
关注(0)|答案(2)|浏览(291)

Please, I have been having trouble for weeks now trying to install and run tensorflow and keras in R Studio. I have tried everything I can find online to no avail. I have anaconda installed on my system, do I need to uninstall it? After running this line of code:

install_tensorflow(method = "conda",version = "default", envname = "py3.6",
                   conda_python_version = "3.6",
                   extra_packages = c("matplotlib","numpy","pandas","scikit-learn"))
install_keras(method = "conda")

It says installation successful, but when I now run tf$constant("Hellow Tensorflow") I get the following error message:

Error: Installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
 C:\Users\IFEANYI\AppData\Local\r-miniconda\envs\r-reticulate\python.exe

You can install TensorFlow using the install_tensorflow() function.

I also try to install keras using:

install_keras(method = "conda")
install_keras(tensorflow = "default")

But I also get an error message:

Error in install_keras(method = "conda") : 
  You should call install_keras() only in a fresh R session that has not yet initialized Keras and TensorFlow (this is to avoid DLL in use errors during installation)

I also have reticulate installed in R Studio. I honestly do not know why it is such a task to install and run tensorflow in R for windows 10. I have been on it for weeks without any tangible headway. Please, as always I will be extremely grateful if someone can help me resolve this nagging issue

ghhaqwfi

ghhaqwfi1#

最近R包中的安装路径有重大更改。2您可以尝试以下操作(在全新的R会话中)吗?

install.packages("keras")
reticulate::install_miniconda()
keras::install_keras()

如果以上方法不起作用,您能否提出问题:https://github.com/rstudio/keras/issues/new

elcex8rz

elcex8rz2#

如果你在RStudio的项目环境中工作,我建议你使用RStudio右上方滑块中的Close Project选项关闭项目。确保你已经在你的系统上安装了Python,并尝试以下代码(根据你系统的用户名更改Username):

library(keras)
library(tensorflow)
library(reticulate)
path_to_python <- "C:/Users/Username/AppData/Local/Programs/Python/Python310"
virtualenv_create("r-reticulate", python = path_to_python)
install_tensorflow(envname = "r-reticulate")
install_keras(envname = "r-reticulate")
use_virtualenv("r-reticulate")

我希望它能起作用。

相关问题