【问题标题】:"It is a distutils installed project ..." when calling install_mlflow()“这是一个 distutils 安装的项目......”调用 install_mlflow() 时
【发布时间】:2021-12-29 22:23:17
【问题描述】:

当调用install_mlflow()为R安装mlflow时,遇到如下错误。

尝试卸载:证书 找到现有安装:certifi 2018.4.16 错误:无法卸载“证书”。这是一个 distutils 安装的项目,因此我们无法准确确定哪些文件属于它,这只会导致部分卸载。

注意:以上是使用miniconda使用install_miniconda()命令安装的。


附:为了大家的利益发布问题和答案(我花了 2 天时间)。

【问题讨论】:

    标签: r rstudio mlflow


    【解决方案1】:

    根本原因:

    函数install_mlflow()调用reticulate::conda_install()函数,默认值为pip_ignore_installed,结果是FALSE

    ? 提示:按住 cmd 键的同时点击脚本中的任意函数即可查看源代码。

    解决方法:

    您可以通过使用pip_ignore_installed = TRUE 调用函数来解决此问题。为方便起见,我在下面的脚本中重新创建了 install_mlflow() 函数。

    如果未安装,该脚本还会检查并安装miniconda

    library(reticulate)
    library(mlflow)
    
    
    # Installing minicoda if not installed
    if (!dir.exists(miniconda_path()))
      install_miniconda(path = miniconda_path(), update = TRUE, force = TRUE)
    
    # install_mlflow() # This doesn't work so we use the alt fn below.
    install_mlflow_alt <- function() {
      mlflow_version <- utils::packageVersion("mlflow")
      packages <- c(paste("mlflow", "==", mlflow_version, sep = ""))
      # Geting mlflow conda bin
      conda_home <- Sys.getenv("MLFLOW_CONDA_HOME", NA)
      conda <- if (!is.na(conda_home)) {
        paste(conda_home, "bin", "conda", sep = "/")
      } else {
        "auto"
      }
      conda_try <- try(conda_binary(conda = conda), silent = TRUE)
      if (class(conda_try) == "try-error") {
        msg <- paste(attributes(conda_try)$condition$message, 
                     paste("  If you are not using conda, you can set the environment variable", 
                           "MLFLOW_PYTHON_BIN to the path of your python executable."), 
                     sep = "\n")
        stop(msg)
      }
      conda <- conda_try
      # Installing mlflow
      mlflow_conda_env_name <- paste("r-mlflow", mlflow_version, sep = "-")
      conda_install(packages, envname = mlflow_conda_env_name, 
                    pip = TRUE, conda = conda, pip_ignore_installed = TRUE)
    }
    
    # NOTE: Run the following command in terminal (use pip3 for python 3)
    #       before calling the install_mlflow_alt() function below
    # paste("pip install -U mlflow==", mlflow:::mlflow_version(), sep="")
    install_mlflow_alt()
    

    【讨论】:

      猜你喜欢
      • 2019-05-17
      • 2021-11-18
      • 2020-08-24
      • 1970-01-01
      • 2018-10-12
      • 2018-10-29
      • 1970-01-01
      相关资源
      最近更新 更多