当调用install_mlflow()
为R安装mlflow时,会遇到以下错误。
正在尝试卸载:certific发现现有安装:certificate2018.4.16错误:无法卸载"certific"。这是一个安装了distutils的项目,因此我们无法准确确定哪些文件属于它,这只会导致部分卸载。
注意:以上使用的是使用install_miniconda()
命令安装的miniconda
。
p。S.张贴问题&为每个人的利益回答(我花了两天时间)。
根本原因:
函数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()