2

I am trying to intsall the r interface to keras/tensoflow in R studio following the code bellow:

`install.packages('devtools')
devtools::install_github("rstudio/keras")
devtools::install_github("rstudio/tensorflow")
library(tensorflow)
install_tensorflow(version = "2.8.0")
library(keras)
install_keras()

reticulate::use_condaenv("anaconda3", required = TRUE)`

All things are Ok until install_tensorflow(version = "2.8.0"), the r studio says No non-system installation of Python could be found. Would you like to download and install Miniconda?

I choose because I want to use the python of my our anaconda environment. But when finishing this command line, it has a warning message

Warning message:
In system2(conda, c("run", in_env, run_args, shQuote(cmd), args),:
running command '"C:/Users/jinhu/anaconda3/condabin/conda.bat" 
run --prefix "C:\Users\jinhu\anaconda3" --no-capture-output "python" -c "import os; 
print(os.environ['PATH'])"' had status 1  

In addition, when I input the py_config function to see the available python version, it output:

Error in Sys.setenv(PATH = new_path) : wrong length for argument In addition: Warning message: In system2(conda, c("run", in_env, run_args, shQuote(cmd), args),  :   running command '"C:/Users/jinhu/anaconda3/condabin/conda.bat" run --prefix "C:\Users\jinhu\anaconda3\envs\r-reticulate" --no-capture-output "python" -c "import os; print(os.environ['PATH'])"' had status 1

below is my conda list:

conda_list()           
name                                  python         
base                     C:\\Users\\jinhu\\anaconda3/python.exe      
pytorch      C:\\Users\\jinhu\\anaconda3\\envs\\pytorch/python.exe 
r-reticulate C:\\Users\\jinhu\\anaconda3\\envs\\r-reticulate/python.exe    
tensorflow   C:\\Users\\jinhu\\anaconda3\\envs\\tensorflow/python.exe

Here is my conda verson:

    (base) C:\Users\jinhu>conda info

     active environment : base
    active env location : C:\Users\jinhu\anaconda3
            shell level : 1
       user config file : C:\Users\jinhu\.condarc
 populated config files : C:\Users\jinhu\.condarc
          conda version : 4.10.3
    conda-build version : 3.21.6
         python version : 3.9.7.final.0
       virtual packages : __cuda=11.4=0
                          __win=0=0
                          __archspec=1=x86_64
       base environment : C:\Users\jinhu\anaconda3  (writable)
      conda av data dir : C:\Users\jinhu\anaconda3\etc\conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\jinhu\anaconda3\pkgs
                          C:\Users\jinhu\.conda\pkgs
                          C:\Users\jinhu\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\jinhu\anaconda3\envs
                          C:\Users\jinhu\.conda\envs
                          C:\Users\jinhu\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.10.3 requests/2.26.0 CPython/3.9.7 Windows/10 Windows/10.0.22000
          administrator : False
             netrc file : None
           offline mode : False

Also when I try use_condaenv( "r-reticulate"), it shows:

`Error in Sys.setenv(PATH = new_path) : wrong length for argument In addition: Warning message: In system2(conda, c("run", in_env, run_args, shQuote(cmd), args),  :   running command '"C:/Users/jinhu/anaconda3/condabin/conda.bat" run --prefix "C:\Users\jinhu\anaconda3\envs\r-reticulate" --no-capture-output "python" -c "import os; print(os.environ['PATH'])"' had status 1`

I think the question is new-created r-reticulate environment cannot find the available python, what should I do to solve it?

Jinhu Li
  • 21
  • 2

0 Answers0