Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keras failure in R after using in python with Anaconda #733

Closed
NigelKinney opened this issue Apr 8, 2019 · 16 comments
Closed

Keras failure in R after using in python with Anaconda #733

NigelKinney opened this issue Apr 8, 2019 · 16 comments

Comments

@NigelKinney
Copy link

Hello,

I have had some weird issues: I mainly used keras on R, but last week I had to do that in python, and then today I realized that my keras installation in RStudio.

I got this error for all keras functions; such as .

model <- keras_model_sequential()

or

rray_reshape(x = xtrain, dim = list(dim(xtrain)[1], 1, dim(xtrain)[2]))

keras Error: lexical error: invalid char in json text. WARNING: The conda.compat module

But when I uninstall anaconda, then I could use my keras.
Does anyone know what may be happening. (I am okay without Anaconda, but it is not that convenient as I do need to use Python occasionally)

@BrianCollinss
Copy link

BrianCollinss commented Apr 8, 2019

I am working on Windows 10 and R/3.5.0. Apparently Keras has some incompatibility with Python 3.7. The thing is that Tensorflow 1.13.1 is dependent on Python 3.7! I don't know how I can install. I cannot get Tensorflow installed with Python 3.7 and 3.6 on Anacondra. It only works with stand-along installations of Python. Any solution?

ibrary(keras)
> install_keras()
Error: lexical error: invalid char in json text.
                                       WARNING: The conda.compat modul
                     (right here) ------^

> library(keras)
> install_keras(method='conda')
Error: lexical error: invalid char in json text.
                                       WARNING: The conda.compat modul
                     (right here) ------^

@dfalbel
Copy link
Member

dfalbel commented Apr 8, 2019

This may help: rstudio/tensorflow#311

This issue is probably related to reticulate and we already have 2 open issues there eg. rstudio/reticulate#475 and rstudio/reticulate#474

@NigelKinney
Copy link
Author

@dfalbel @BenAbabaei . Thank you for your reply.

I think downgrading the python (#311) will help as I did a pip update python when I was writing the codes in jupyternotebooks, which created that problem. Thanks a lot!

@dfalbel
Copy link
Member

dfalbel commented Apr 8, 2019

This has been solved, see here: rstudio/reticulate#475

@dfalbel dfalbel closed this as completed Apr 8, 2019
@NigelKinney
Copy link
Author

I have seen the #475 reticulate post, but it does not solve my problem. Re-installing reticulate does not solve the problem.

The only solution I have now is to force to downward python 3.7 to python 3.6; then everything seems ok at the moment.

@NigelKinney
Copy link
Author

NigelKinney commented Apr 9, 2019 via email

@dfalbel
Copy link
Member

dfalbel commented Apr 9, 2019

Are you on a clean session? Can you share your tf_config() and sessionInfo() please?

@NigelKinney
Copy link
Author

NigelKinney commented Apr 9, 2019 via email

@BrianCollinss
Copy link

BrianCollinss commented Apr 10, 2019

> library(keras)
> install_keras()
Error: lexical error: invalid char in json text.
                                       WARNING: The conda.compat modul
                     (right here) ------^
> 
> tf_config()
Error: lexical error: invalid char in json text.
                                       WARNING: The conda.compat modul
                     (right here) ------^
> sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252    LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C                       LC_TIME=English_Australia.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] keras_2.2.4.1.9000     tensorflow_1.13.1.9000

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1        compiler_3.5.3    prettyunits_1.0.2 base64enc_0.1-3   remotes_2.0.2     tools_3.5.3       zeallot_0.1.0    
 [8] testthat_2.0.1    digest_0.6.18     pkgbuild_1.0.3    pkgload_1.0.2     jsonlite_1.6      memoise_1.1.0     lattice_0.20-38  
[15] rlang_0.3.4       Matrix_1.2-15     cli_1.1.0         rstudioapi_0.10   curl_3.3          yaml_2.2.0        withr_2.1.2      
[22] generics_0.0.2    desc_1.2.0        fs_1.2.7          devtools_2.0.1    rprojroot_1.3-2   grid_3.5.3        reticulate_1.11.1
[29] glue_1.3.1        R6_2.4.0          processx_3.3.0    sessioninfo_1.1.1 callr_3.2.0       magrittr_1.5      whisker_0.3-2    
[36] backports_1.1.3   ps_1.3.0          tfruns_1.4        usethis_1.4.0     assertthat_0.2.1  crayon_1.3.4

@dfalbel
Copy link
Member

dfalbel commented Apr 10, 2019

Please install the dev version of reticulate:

devtools::install_github("rstudio/reticulate")

@BrianCollinss
Copy link

> devtools::install_github("rstudio/reticulate")
Downloading GitHub repo rstudio/reticulate@master
√  checking for file 'C:\Users\uqbababa\AppData\Local\Temp\RtmpMdeum0\remotes25010b153ef\rstudio-reticulate-41706b4/DESCRIPTION' ... 
-  preparing 'reticulate': (745ms)
√  checking DESCRIPTION meta-information ... 
-  cleaning src
-  checking for LF line-endings in source and make files and shell scripts (413ms)
-  checking for empty or unneeded directories
-  building 'reticulate_1.11.1-9000.tar.gz'
   
Installing package into ‘C:/Users/uqbababa/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
* installing *source* package 'reticulate' ...
** libs

*** arch - i386
C:/RBuildTools/3.5/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-35~1.3/include" -DNDEBUG  -I"C:/Users/uqbababa/Documents/R/win-library/3.5/Rcpp/include"        -O2 -Wall  -mtune=generic -c RcppExports.cpp -o RcppExports.o
C:/RBuildTools/3.5/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-35~1.3/include" -DNDEBUG  -I"C:/Users/uqbababa/Documents/R/win-library/3.5/Rcpp/include"        -O2 -Wall  -mtune=generic -c event_loop.cpp -o event_loop.o
C:/RBuildTools/3.5/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-35~1.3/include" -DNDEBUG  -I"C:/Users/uqbababa/Documents/R/win-library/3.5/Rcpp/include"        -O2 -Wall  -mtune=generic -c libpython.cpp -o libpython.o
C:/RBuildTools/3.5/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-35~1.3/include" -DNDEBUG  -I"C:/Users/uqbababa/Documents/R/win-library/3.5/Rcpp/include"        -O2 -Wall  -mtune=generic -c output.cpp -o output.o
C:/RBuildTools/3.5/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-35~1.3/include" -DNDEBUG  -I"C:/Users/uqbababa/Documents/R/win-library/3.5/Rcpp/include"        -O2 -Wall  -mtune=generic -c python.cpp -o python.o
C:/RBuildTools/3.5/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-35~1.3/include" -DNDEBUG  -I"C:/Users/uqbababa/Documents/R/win-library/3.5/Rcpp/include"        -O2 -Wall  -mtune=generic -c readline.cpp -o readline.o
C:/RBuildTools/3.5/mingw_32/bin/g++ -shared -s -static-libgcc -o reticulate.dll tmp.def RcppExports.o event_loop.o libpython.o output.o python.o readline.o -LC:/PROGRA~1/R/R-35~1.3/bin/i386 -lR
installing to C:/Users/uqbababa/Documents/R/win-library/3.5/reticulate/libs/i386

*** arch - x64
C:/RBuildTools/3.5/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-35~1.3/include" -DNDEBUG  -I"C:/Users/uqbababa/Documents/R/win-library/3.5/Rcpp/include"        -O2 -Wall  -mtune=generic -c RcppExports.cpp -o RcppExports.o
C:/RBuildTools/3.5/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-35~1.3/include" -DNDEBUG  -I"C:/Users/uqbababa/Documents/R/win-library/3.5/Rcpp/include"        -O2 -Wall  -mtune=generic -c event_loop.cpp -o event_loop.o
C:/RBuildTools/3.5/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-35~1.3/include" -DNDEBUG  -I"C:/Users/uqbababa/Documents/R/win-library/3.5/Rcpp/include"        -O2 -Wall  -mtune=generic -c libpython.cpp -o libpython.o
C:/RBuildTools/3.5/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-35~1.3/include" -DNDEBUG  -I"C:/Users/uqbababa/Documents/R/win-library/3.5/Rcpp/include"        -O2 -Wall  -mtune=generic -c output.cpp -o output.o
C:/RBuildTools/3.5/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-35~1.3/include" -DNDEBUG  -I"C:/Users/uqbababa/Documents/R/win-library/3.5/Rcpp/include"        -O2 -Wall  -mtune=generic -c python.cpp -o python.o
C:/RBuildTools/3.5/mingw_64/bin/g++  -I"C:/PROGRA~1/R/R-35~1.3/include" -DNDEBUG  -I"C:/Users/uqbababa/Documents/R/win-library/3.5/Rcpp/include"        -O2 -Wall  -mtune=generic -c readline.cpp -o readline.o
C:/RBuildTools/3.5/mingw_64/bin/g++ -shared -s -static-libgcc -o reticulate.dll tmp.def RcppExports.o event_loop.o libpython.o output.o python.o readline.o -LC:/PROGRA~1/R/R-35~1.3/bin/x64 -lR
installing to C:/Users/uqbababa/Documents/R/win-library/3.5/reticulate/libs/x64
Error in file.copy(files, dest, overwrite = TRUE) : 
  (converted from warning) problem copying .\reticulate.dll to C:\Users\uqbababa\Documents\R\win-library\3.5\reticulate\libs\x64\reticulate.dll: Permission denied
* removing 'C:/Users/uqbababa/Documents/R/win-library/3.5/reticulate'
* restoring previous 'C:/Users/uqbababa/Documents/R/win-library/3.5/reticulate'
Error in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE) : 
  (converted from warning) problem copying C:\Users\uqbababa\Documents\R\win-library\3.5\00LOCK-reticulate\reticulate\libs\x64\reticulate.dll to C:\Users\uqbababa\Documents\R\win-library\3.5\reticulate\libs\x64\reticulate.dll: Permission denied
Execution halted
In R CMD INSTALL
Error in i.p(...) : 
  (converted from warning) installation of package ‘C:/Users/uqbababa/AppData/Local/Temp/RtmpMdeum0/file250374f2435/reticulate_1.11.1-9000.tar.gz’ had non-zero exit status

@dfalbel
Copy link
Member

dfalbel commented Apr 10, 2019

This seems like a "permission denied" issue. Are you admin on this machine?

@BrianCollinss
Copy link

@dfalbel I am. I just wonder why I get that error with 'conda' json file.

@dfalbel
Copy link
Member

dfalbel commented Apr 10, 2019

This error is related to reticulate and has been fixed in the dev version. See here: rstudio/reticulate#474

@BrianCollinss
Copy link

BrianCollinss commented Apr 10, 2019

I reinstalled reticulate from GitHub and it worked! So much trouble for a warning :) Cheers.

@rgurlek
Copy link

rgurlek commented Apr 10, 2019

Installing reticulate from Github worked. I had to use argument INSTALL_opts = c('--no-lock').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants