我正在尝试在本地R服务器上安装并运行“ KoNLP”。 但不知何故,我不断收到如下错误
Error: package or namespace load failed for ‘KoNLP’:
.onLoad failed in loadNamespace() for 'KoNLP', details:
call: fun(libname, pkgname)
error: You cann't parse resource files based on UTF-8 on rJava.
Please reload KoNLP first than any other packages connected with
rJava.
我安装了Java并使用
分配了Java主目录Sys.setenv(JAVA_HOME =
'/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre')
dyn.load('/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/server/libjvm.dylib')
我不知道为什么我总是收到这个错误。 有人可以帮帮我吗? 谢谢!
答案 0 :(得分:0)
if(dir.exists(paste(Sys.getenv("PROGRAMFILES"), "\\Java\\", sep = ""))){
Javapath <- paste(Sys.getenv("PROGRAMFILES"), "\\Java\\", sep = "")
Javapath <- paste(Javapath, list.files(path = Javapath, pattern = "jdk"), "\\",sep = "")
if(grepl("jdk", Javapath)){
options(java.home=Javapath[which.max(gsub(".*jdk[0-9]+\\.[0-9]+\\.[0-9]+_|\\\\$", "", Javapath))])
}else{
Javapath <- paste(Sys.getenv("PROGRAMFILES"), "\\Java\\", sep = "")
Javapath <- paste(Javapath, list.files(path = Javapath, pattern = "jre"), "\\",sep = "")
options(java.home=Javapath[which.max(gsub(".*jre[0-9]+\\.[0-9]+\\.[0-9]+_|\\\\$", "", Javapath))])
}
}else if(dir.exists(paste(Sys.getenv("PROGRAMFILES(x86)"), "\\Java\\", sep = ""))){
Javapath <- paste(Sys.getenv("PROGRAMFILES(x86)"), "\\Java\\", sep = "")
Javapath <- paste(Javapath, list.files(path = Javapath, pattern = "jre"), "\\",sep = "")
options(java.home=Javapath[which.max(gsub(".*jre[0-9]+\\.[0-9]+\\.[0-9]+_|\\\\$", "", Javapath))])
}
也许您可以尝试设置选项(java.home =“ java的路径”)