Rothschild
Rothschild

Reputation: 39

Downloading MNIST data from Keras results in; Error in Sys.setenv(PATH = new_path) : wrong length for argument

I am working on Image Analysis and Classification in R. I loaded in

library(tensorflow)
library(keras)

I tried downloading the in-built Fashion-MNIST dataset from Keras library

mydata <- dataset_fashion_mnist()

which results in the following error message

Error in Sys.setenv(PATH = new_path) : wrong length for argument

Some few days ago, I added RTools path to the Windows environment variable PATH using the following lines of code

rtools <- "C:\\RTools\\bin"
gcc <- "C:\\RTools\\gcc-4.6.3\\bin"
path <- strsplit(Sys.getenv("PATH"), ";")[[1]]

new_path <- c(rtools, gcc, path)
new_path <- new_path[!duplicated(tolower(new_path))]

Sys.setenv(PATH = paste(new_path, collapse = ";"))

I think this is what is causing the Error in Sys.setenv(PATH = new_path) : wrong length for argument error message when I tried downloading MNIST data from Keras.

My PATH is

Sys.getenv("PATH")
1] "C:\\RTools\\bin;C:\\RTools\\gcc-4.6.3\\bin;C:\\rtools40\\usr\\bin;C:\\Program Files\\R\\R-4.1.0\\bin\\x64;C:/Users/Admin/Documents/R/win-library/4.1;C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python310\\Scripts\\;C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python310\\;C:\\Users\\Admin\\anaconda3;C:\\Users\\Admin\\anaconda3\\Library\\mingw-w64\\bin;C:\\Users\\Admin\\anaconda3\\Library\\usr\\bin;C:\\Users\\Admin\\anaconda3\\Library\\bin;C:\\Users\\Admin\\anaconda3\\Scripts;C:\\Program Files\\MySQL\\MySQL Shell 8.0\\bin\\;C:\\Users\\Admin\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files\\Azure Data Studio\\bin;C:\\Program Files\\JetBrains\\PyCharm Community Edition 2022.2\\bin;;C:\\Users\\Admin\\AppData\\Roaming\\TinyTeX\\bin\\win32;C:\\Program Files\\Java\\jdk1.8.0_191\\bin;C:\\Users\\Admin\\Documents\\R\\win-library\\4.1;C:\\rtools40;C:\\Program Files\\R\\R-4.1.0\\bin"

Please how do I solve this error? R version 4.1.0, with RTools installed. Windows 10

traceback output gives:

13: Sys.setenv(PATH = new_path)
12: python_munge_path(python)
11: python_config(miniconda_python, NULL, miniconda_python)
10: py_discover_config(required_module, use_environment)
9: (function() {
       op <- options(reticulate.python.initializing = TRUE)
       on.exit(options(op), add = TRUE)
       py_discover_config(required_module, use_environment)
   })()
8: initialize_python(required_module, use_environment)
7: ensure_python_initialized()
6: py_config()
5: py_config_error_message(paste("Python module", module, "was not found."))
4: py_resolve_module_proxy(x)
3: `$.python.builtin.module`(keras, "datasets")
2: keras$datasets
1: dataset_fashion_mnist()

Please what can I do to resolve this?

Upvotes: 1

Views: 99

Answers (0)

Related Questions