错误:软件包是由具有不同内部结构的R版本安装的;需要重新安装 [英] Error: package was installed by an R version with different internals; it needs to be reinstalled

查看:43
本文介绍了错误:软件包是由具有不同内部结构的R版本安装的;需要重新安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到程序包安装问题,我完全不知道如何管理此情况。

install.packages("C:/Users/Oliver/Downloads/NPRED.zip", repos = NULL, type = "win.binary")
Installing package into ‘C:/Users/Oliver/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
package ‘NPRED’ successfully unpacked and MD5 sums checked
library("NPRED", lib.loc="~/R/win-library/3.5")

*

> Error: package or namespace load failed for ‘NPRED’:
>      package ‘NPRED’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version

*

有人能帮我解决那个问题吗??

非常感谢! 干杯, OLLI

推荐答案

# Find the currently installed packages, put this in a data frame
df_all_packages <- as.data.frame(installed.packages())

请查看这个,以检查有哪些主要版本和次要R版本。

View(df_all_packages)
table(df_all_packages$Built) # how many packages built under each version of R
下面的示例假设您使用的是R4,并且希望升级一些基于R3.6的软件包。您应该根据自己的情况进行调整。

# Find older package versions, make a list with packages which are of older version and you want to update
df_packages_to_upgrade <- as.data.frame(subset(df_all_packages, (Built %in% c('3.6.1', '3.6.2','3.6.3'))))
# Or you can prefer to base the filtering on those you want to keep, if so uncomment next line:
# df_packages_to_upgrade <- as.data.frame(subset(df_all_packages, !(Built %in% c('4.0.1', '4.0.2','4.0.3'))))

# Finally re-install the packages :
install.packages(df_packages_to_upgrade$Package)

有时,上述操作会失败。特定包的依赖关系可能会发生变化,这可能很难跟踪;这可能涉及到棘手的操作系统级别依赖关系。在一种情况下,我必须这样做:

# At bash command line, as root:
yum install jq-devel protobuf-devel libcurl-devel openssl-devel geos-devel gdal gdal-devel proj-devel proj-nad proj-epsg libjpeg-turbo*
# use 'apt-get install' on Debian-based
# Then, in R (as linux super-user), remove all old packages - but before, make a copy-paste of the list, just in case
# The list:
old_packages_removed <- rownames(df_packages_to_upgrade)

remove.packages(df_packages_to_upgrade$Package)
# Then I installed the 2 or 3 packages I really needed, which ended up installing 50 packages (most of the previously un-installed ones)
# You could try, instead:
install.packages(old_packages_removed)

这为我解决了问题。

这篇关于错误:软件包是由具有不同内部结构的R版本安装的;需要重新安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆