R: Namespace Load Failed for 'Mxnet': Package 'Mxnet' Was Installed Before R 4.0.0: Please Re-Install It

Package ‘XXX’ was installed before R 4.0.0: please re-install it

All packages need to be reinstalled under the new version (4.0). I had to first remove and then reinstall all the packages.

The following worked for me:

# check your package library path 
.libPaths()

# grab old packages names
old_packages <- installed.packages(lib.loc = "/Library/Frameworks/R.framework/Versions/3.6/Resources/library")
old_packages <- as.data.frame(old_packages)
list.of.packages <- unlist(old_packages$Package)

# remove old packages
remove.packages( installed.packages( priority = "NA" )[,1] )

# reinstall all packages
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
lapply(list.of.packages,function(x){library(x,character.only=TRUE)})

Package 'xxx’ was installed before R 4.0.0: please re-install it (already done fresh install and checked lib paths)

The error message is maybe a bit confusing, but it's saying the package is already compiled for an earlier version of R. (That's what the option "win.binary" means).

R 4.0 and earlier binaries are not compatible because of updated compilers and build tools.

You'll need to install the package from source, which likely means installing R tools (https://cran.r-project.org/bin/windows/Rtools/) or you'll need to use a version that is pre-built for R 4.0 or later.

MXNet package installation in R

For mxnet package install in R using this command for only CPU

cran <- getOption("repos")
cran["dmlc"] <- "https://s3-us-west-2.amazonaws.com/apache-mxnet/R/CRAN/"
options(repos = cran)
install.packages("mxnet",dependencies = T)
library(mxnet)

Causes of Error: package '_____' was built before 3.0.0: please re-install it in R

Running install.packages("codetools") can fix this issue for R 3.0.2, if you have the same problem like me:

installing to /home/user/R/x86_64-pc-linux-gnu-library/3.0/Rcpp/libs
** R
** inst
** preparing package for lazy loading
Error : package ‘**codetools**’ was built before R 3.0.0: please re-install it
Error : unable to load R code in package ‘Rcpp’
ERROR: lazy loading failed for package ‘Rcpp’


Related Topics



Leave a reply



Submit