0

If I run the following code:

install_keras()

I get the following errors:

Error in python_config_impl(python) : 

Error 1 occurred running /usr/bin/python3: In addition: Warning messages: 1: In system2(command = python, args = shQuote(script), stdout = TRUE, : running command ''/usr/bin/python3' '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/reticulate/config/config.py' 2>/dev/null' had status 1 2: In system2(command = python, args = shQuote(script), stdout = TRUE, : running command ''/usr/bin/python3' '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/reticulate/config/config.py' 2>/dev/null' had status 1

Somehow, I have managed to install keras (I don't remember how) as it shows up in my R packages.

But, when I run these codes:

library(keras)
is_keras_available()

I get this answer:

[1] FALSE

Warning message: In system2(command = python, args = shQuote(script), stdout = TRUE, : running command ''/usr/bin/python3' '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/reticulate/config/config.py' 2>/dev/null' had status 1

Sympa
  • 125
  • 1
  • 1
  • 16

1 Answers1

1

I got exactly the same error as you when I tried to run install_keras(). I think the problem is when configuring Python in R, R couldn't find a Python environment for path '/usr/bin/python3'.

The following command line produces couple paths to choose from:

which -a python python3

What I did is that I install library 'reticulate' in R and run the following code.

library(reticulate)
use_python("/Users/[user_name]/opt/anaconda3/bin/python3") #Select the version of Python to be used by reticulate.

Then I called the library 'keras' again

library(keras)
install_keras()

And it worked!

Posts that I found useful to this problem:

Unable to change Python path in reticulate

https://rstudio.github.io/reticulate/articles/versions.html

Python in R - Error: could not find a Python environment for /usr/bin/python

Pei
  • 26
  • 2