I´m trying to install Tensorflow on Rstudio windows.
I have installed, Anaconda 3, all my R librarys are updated, and load library Keras on R
When I try to install, using:
install_keras()
The installation was not completed and an error message prompt:
Error: Error 2 occurred installing packages into conda environment r-tensorflow
In addition: Warning message:
"running command '"C:/PROGRA~3/ANACON~1/Scripts/activate" r-tensorflow && pip install --upgrade --ignore-installed https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.3.0-cp36-cp36m-win_amd64.whl had status 2"
Can someone help me in this issue?
Thanks!!!
I got the same error. I think it is because tensorflow is already installed through the install of keras. If I try to install keras again, I get the error that keras and tensorflow can only be installed in a fresh R session, where they had not been installed before. Otherwise there might be dll error. So it appears to me that you do not (and should not) install tensorflow if you have already installed keras. When I stopped Rstudio and started it again, I could install keras and re-install tensorflow through.
Related
I would like to install Keras and Tensorflow for R and I don't know why but I can't. I got a Miniconda installation though.
Even if I try to use my Miniconda path I still have the same error when I try to install Keras or Tensorflow I get the same error.
Here's my code:
use_condaenv("miniconda3", required = TRUE)
install.packages('keras')
install.packages('tensorflow')
library(keras)
library(tensorflow)
install_keras()
install_tensorflow()
The error comes with install_keras() (or install_tensorflow(), whatever the first row is):
Error: installation of 'python=3.7' into environment '.../r-miniconda/envs/r-reticulate' failed [error code 1]
But this is not my miniconda3 path. I'm using this path for r-reticulate in order to generate R Markdown documents including both R and Python code.
Is there a simple way to install Keras and Tensorflow for R?
Thanks so much
First, we need to make sure we have DevTools installed so we can import the necessary packages, then install Keras.
install.packages("devtools")
devtools::install_github("rstudio/keras")
I have installed tensorflow in r with this code install_tensorflow(conda_python_version = '3.8').
When calling tf$constant('Hellow Tensorflow'), I get this error:
Error: Installation of TensorFlow not found.
Python environments searched for 'tensorflow' package:
C:\Users\User\.conda\envs\r-reticulate\python.exe
C:\ProgramData\Anaconda3\python.exe
You can install TensorFlow using the install_tensorflow() function.
However, I have the python.exe in the first location and have the library in C:\Users\User\.conda\envs\r-reticulate\Lib\site-packages\tensorflow\. Why the tensorflow installation could not be found?
I have solved this by typing conda activate r-reticulate to anaconda powershell while having the tensorflow installed in the r-reticulate environment.
I used to work in R 3.4.0 version. Hovewer, this version doesn't support such packages as keras and tensorflow.
I was adviced to upgrade my R version to the newest one.
I downloaded the most recent R version 4.0.2 from the official site, then ran the following code:
install.packages("keras")
library(keras)
install_keras()
And got the following error:
Error in install_keras() :
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)
After this, when I tried to quit R session by q() , I faced the following error:
Error: option error has NULL value
Error: no more error handlers available (recursive errors?); invoking 'abort' restart
Error: option error has NULL value
I've never faced such an error before. When I used old R version, I typed q() and then had to choose between y and n. No errors appeared.
I'm asking you to help to to solve this problem.
You need to create a new environment and then you can install R 4.+ in Anaconda. Follow these steps.
conda create --name r4-base
After activating r4-base run these commands
conda activate r4-base
conda install -c conda-forge r-base
conda install -c conda-forge/label/gcc7 r-base
Finally, you will notice r-basa version 4 will be installed.
Thereafter, you can install any supported packages. But with this only, you won't have the ability to use it in the Jupyter notebook. You need to install install.packages('IRkernel') and Jupyter notebook as well if you want to use it. Otherwise you are good to go with R-Studio.
For Jupyter Installation and RKernel.
conda install jupyter
Then open the R console. Write in R console
install.packages('IRkernel')
IRkernel::installspec()
Congrats! You can use Notebook for Python and R.
Find the location of R.exe on your computer. In my computer, this executable is at
C:\Program Files\R\R-3.4.3\bin
Open another Anaconda Prompt as Administrator and change directories to wherever R.exe is on your computer with cd file path. On my computer, it’s cd C:\Program Files\R\R-3.4.3\bin, but it might be different for you.
Then run R from within Anaconda Prompt in Admin mode with R.exe
You’ll notice that you’re in an R session. From here, run the following three commands into the terminal.
install.packages("devtools")
devtools::install_github("IRkernel/IRkernel")
IRkernel::installspec()
In order, they (1) install the devtools package which gets you the install_github() function, (2) install the IR Kernel from GitHub, and (3) tell Jupyter where to find the IR Kernel.
Open Jupyter notebook and enjoy your new R kernel!
Get more information here
#Rheatey Bash works perfectly. but i was facing python.exe this program cant start because api-ms-win-core-path-l1-1-0.dll python system error. this is a problem running on windows 7 but i resolved this issue by installing the kernel following https://richpauloo.github.io/2018-05-16-Installing-the-R-kernel-in-Jupyter-Lab/ and it works fine
I'm using windows, my problem is that while trying to install tensorflow in R the following error message appears.
Error in install_tensorflow(method = method, conda = conda, version = tensorflow, :
Unable to install TensorFlow on this platform.Binary installation is only available for 64-bit platforms.
My machine is 64 bit, so I don't understand where is the problem.
I've already cheked if my anaconda installation and the python version are 64bit and they are.
I can install tensorflow in python without any error, but i can't in R.
I've tried to redirect the R tensorflow installation to the python environment but i don't know if it can really help.
> library(tensorflow)
> install_tensorflow()
Error in install_tensorflow() :
Unable to install TensorFlow on this platform.Binary installation is only available for 64-bit platforms.
Can you try to install older version of tensorflow which is 1.5.0 using command pip install tensorflow==1.5.0
I am trying to install tensorflow on R. As far as I understand I have already installed successlly many times but it won't load
Everytime I run a function from Tensorflow and Keras it does not work.
> testlabels=to_categorical(trainy)
Error: Python module tensorflow.python.keras was not found.
Detected Python configuration:
python: C:\Users\AUSTER~1\ANACON~1\python.exe
libpython: C:/Users/AUSTER~1/ANACON~1/python37.dll
pythonhome: C:\Users\AUSTER~1\ANACON~1
version: 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)]
Architecture: 64bit
numpy: C:\Users\AUSTER~1\ANACON~1\lib\site-packages\numpy
numpy_version: 1.16.4
tensorflow: [NOT FOUND]
When I load the libraries I have no issues. They all load up sucessfully.
library(EBImage)
library(keras)
library(tensorflow)
I have ran all these following commands.
install.packages("keras")
source("http://bioconductor.org/biocLite.R")
biocLite("EBImage")
install.packages("reticulate")
install.packages("remotes")
remotes::install_github("rstudio/tensorflow")
reticulate::py_discover_config("keras")
reticulate::py_discover_config("tensorflow")
install.packages("devtools")
devtools::install_github("rstudio/keras")
tensorflow::install_tensorflow()
devtools::install_github("rstudio/keras")
What could be causing the issue. After I installed tensforflow it said "Installation Complete" and then restarted R. Is R simply unable to find the installation?
I have also ran the following commands still with no luck.
library(tensorflow)
Sys.setenv(TENSORFLOW_PYTHON="/usr/local/bin/python")
Update
I was able to get Tensorflow/Keras to work by opening an Anaconda command prompt and running the following commands. Then my R code using Keras/Tensorflow started to work.
conda install -c conda-forge keras
The keras package makes use of keras through python. When you install the package, it installs the R interface, but not the python package. You must separately install the python package. There is a nice guide for doing that on RBloggers
I checked all of the suggestions. None of them worked.
This worked for me on Windows 10
1- Open rstudio and uninstall these package if you already installed using:
uninstall.packages(c("keras", "tensorflow","tfruns"))
2- uninstall rtools from your computer if exists
3- Install Anaconda from https://www.anaconda.com/products/individual
4- Install the last version of rtools from https://cran.r-project.org/bin/windows/Rtools/
5- Close rstudio if it is opened
6- open new session and write this:
install.packages("reticulate")
install.packages("remotes")
library("reticulate")
remotes::install_github("rstudio/tensorflow")
library(tensorflow)
install_tensorflow(version = "2.0.0b1", method = "conda", envname = "r-reticulate")
remotes::install_github("rstudio/keras", dependencies = TRUE)
library(keras)
7- check if they work:
#if tensorflow works
tf$abs(-1)
#if keras works
mnist <- dataset_mnist()
my suggestion is to install anaconda and create an environment called "r-reticulate".
you can do it using anaconda navigator or
reticulate::conda_create(envname = "r-reticulate")
then to check that env detected by reticulate, use reticulate::conda_python().it must return directory of python.exe for your env.
after that you can install tensorflow by install_tensorflow(). [not working in my case]
so I install the tesnorflow from CMD.
follow these steps:
open the cmd :]
activate the r-reticulate env using conda activate r-reticulate (you may need your directory to conda directory if you did not add conda to your PATH)
use : conda install -c anaconda tensorflow
now in R, you can use TensorFlow.
for installing Keras, you can use pip install Keras. [I tried install_keras() function after the installation of tensorflow, but it n