Install and load Tidymodels package in AML

Jean Paul Piedrahita García 6 Reputation points
2022-05-25T20:05:27.043+00:00

I'm trying install and load some R packages in the Execute R Script in Azure Machine Learning for to run models, such as tidymodels, timetk, modeltime, modeltime.ensemble.

library(forecast)
library(tidyverse)
library(lubridate)
install.packages("quantdates",repos = "https://cloud.r-project.org")
install.packages("tidymodels",repos = "https://cloud.r-project.org")
library(quantdates)
library(tidymodels) 
library(timetk) 
library(modeltime) 
library(modeltime.resample) 
library(modeltime.ensemble)

However I get the following error:

Error: package or namespace load failed for ‘tidymodels’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
namespace ‘rlang’ 0.4.5 is already loaded, but >= 1.0.2 is required
azureml_main(input_dataframe_1), library(tidymodels), tryCatch({
    attr(package, "LibPath") <- which.lib.loc
    ns <- loadNamespace(package, lib.loc)
    env <- attachNamespace(ns, pos = pos, deps)
}, error = function(e) {
    P <- if (!is.null(cc <- conditionCall(e))) 
        paste(" in", deparse(cc)[1])
    else ""
    msg <- gettextf("package or namespace load failed for %s%s:\n %s", sQuote(package), P, conditionMessage(e))
    if (logical.return) 
        message(paste("Error:", msg), domain = NA)
    else stop(msg, call. = FALSE, domain = NA)
}), tryCatchList(expr, classes, parentenv, handlers), tryCatchOne(expr, names, parentenv, handlers[[1]]), value[[3]](cond), stop(msg, call. = FALSE, domain = NA), .handleSimpleError(function (e) 
{
    error_msg <<- paste(toString(e), toString(sys.calls()[-c(1:3)]), sep = "\n")
    stop(e)
}, "package or namespace load failed for ‘tidymodels’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):\n namespace ‘rlang’ 0.4.5 is already loaded, but >= 1.0.2 is required", quote(NULL)), h(simpleError(msg, call))
'.
---------- End of error message from R  interpreter  ----------

I have also tried with devtools package for install a particular version but I keep getting the same error with the rlang package. Sometimes, I get the same error with the cli package.

In my local machine, the R code runs fine. I have the R version 4.1.3 and the Azure Machine Learning has the R version 3.5.1.

Does anyone know how I can solve this problem?

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,332 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Jean Paul Piedrahita García 6 Reputation points
    2022-05-27T13:25:28.763+00:00

    @romungi-MSFT After everything I've managed to consult, I think the problem is in the R version 3.5.1: tidymodels package require a rlang version package greater than o equal to 1.0.2. However, the rlang version 1.0.2 only works for R versions starting from 4.0.0:

           Package  Version  Published  
    96           R    3.5.1 2018-07-02  
    97  tidymodels    0.0.1 2018-07-27  
    98       rlang    0.2.2 2018-08-16  
    99       rlang    0.3.0 2018-10-22  
    100      rlang  0.3.0.1 2018-10-25  
    101 tidymodels    0.0.2 2018-11-27  
    102          R    3.5.2 2018-12-20  
    103      rlang    0.3.1 2019-01-08  
    104          R    3.5.3 2019-03-11  
    105      rlang    0.3.2 2019-03-21  
    106      rlang    0.3.3 2019-03-29  
    107      rlang    0.3.4 2019-04-07  
    108          R    3.6.0 2019-04-26  
    109      rlang    0.4.0 2019-06-25  
    110          R    3.6.1 2019-07-05  
    111 tidymodels    0.0.3 2019-10-04  
    112      rlang    0.4.1 2019-10-24  
    113      rlang    0.4.2 2019-11-23  
    114          R    3.6.2 2019-12-12  
    115      rlang    0.4.3 2020-01-24  
    116      rlang    0.4.4 2020-01-28  
    117 tidymodels    0.1.0 2020-02-16  
    118          R    3.6.3 2020-02-29  
    119      rlang    0.4.5 2020-03-01  
    120          R    4.0.0 2020-04-24  
    121      rlang    0.4.6 2020-05-02  
    122          R    4.0.1 2020-06-06  
    123          R    4.0.2 2020-06-22  
    124      rlang    0.4.7 2020-07-09  
    125 tidymodels    0.1.1 2020-07-14  
    126      rlang    0.4.8 2020-10-08  
    127          R    4.0.3 2020-10-10  
    128 tidymodels    0.1.2 2020-11-22  
    129      rlang    0.4.9 2020-11-26  
    130      rlang   0.4.10 2020-12-30  
    131          R    4.0.4 2021-02-15  
    132          R    4.0.5 2021-03-31  
    133 tidymodels    0.1.3 2021-04-19  
    134      rlang   0.4.11 2021-04-30  
    135          R    4.1.0 2021-05-18  
    136          R    4.1.1 2021-08-10  
    137 tidymodels    0.1.4 2021-10-01  
    138      rlang   0.4.12 2021-10-18  
    139      rlang    1.0.0 2022-01-26  
    140      rlang    1.0.1 2022-02-03  
    141      rlang    1.0.2 2022-03-04  
    142 tidymodels    0.2.0 2022-03-19  
    

    For this reason, in the AML only loaded (or manages to load) the rlang version 0.4.5, which the last compatible version for R 3.0.0. The rlang version 1.0.2 only is compatible for R 4.0.0. I wish there was a possibility that AML had a more recent version of R. Thank you again.

    1 person found this answer helpful.
    0 comments No comments

  2. romungi-MSFT 48,906 Reputation points Microsoft Employee Moderator
    2022-05-26T10:49:40.953+00:00

    @Jean Paul Piedrahita García I think the reason that tidymodels failed to install is because it is built on windows as per the Description file of the package.

    Built: R 4.2.0; ; 2022-05-24 05:31:20 UTC; windows  
    

    The note and warning section of Installing R packages from documentation details the way to check if a package can be installed with the Execute R script module.

    Do not install packages which are pre-built on/for Windows, since the designer components are running on Ubuntu. To check whether a package is pre-built on windows, you could go to CRAN and search your package, download one binary file according to your OS, and check Built: part in the DESCRIPTION file.

    If an answer is helpful, please click on 130616-image.png or upvote 130671-image.png which might help other community members reading this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.