在R中安装R包openNLP

时间:2016-05-03 21:05:34

标签: java r opennlp

我正在尝试在R(mac)中安装openNLP包,并不断收到以下错误消息

> install.packages("openNLP")
trying URL 'https://rweb.crmda.ku.edu/cran/bin/macosx/mavericks/contrib/3.2/openNLP_0.2-6.tgz'
Content type 'application/x-gzip' length 32952 bytes (32 KB)
==================================================
downloaded 32 KB


The downloaded binary packages are in
    /var/folders/20/gzm2zpr94pz9dghqd8l5ff1c0000gn/T//Rtmp8n5kNw/downloaded_packages
> library(openNLP)
JavaVM: requested Java version ((null)) not available. Using Java at "" instead.
JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib
JavaVM FATAL: Failed to load the jvm library.
Error : .onLoad failed in loadNamespace() for 'openNLPdata', details:
  call: .jinit()
  error: JNI_GetCreatedJavaVMs returned -1

Error: package or namespace load failed for ‘openNLP’


Here is my R version

> R.Version()

$platform
[1] "x86_64-apple-darwin13.4.0"

$arch
[1] "x86_64"

$os
[1] "darwin13.4.0"

$system
[1] "x86_64, darwin13.4.0"

$status
[1] ""

$major
[1] "3"

$minor
[1] "2.4"

$year
[1] "2016"

$month
[1] "03"

$day
[1] "10"

$`svn rev`
[1] "70301"

$language
[1] "R"

$version.string
[1] "R version 3.2.4 (2016-03-10)"

$nickname
[1] "Very Secure Dishes"

我安装了Java

java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
还安装了

rJava。任何帮助将不胜感激

1 个答案:

答案 0 :(得分:8)

提议的解决方案:

1。在命令行启动R(测试解决方案)

> sudo R CMD javareconf
> export LD_LIBRARY_PATH=$JAVA_LD_LIBRARY_PATH
> LD_LIBRARY_PATH=$(/usr/libexec/java_home)/jre/lib/server: open -a RStudio

现在在RStduio内:

> install.packages("rJava", type = "source")
> install.packages("openNLP")
> require(rJava)
> require(openNLP)

从finder启动RStudio ...(El Capitan)

您必须将libjvm.dylib/usr/lib ...

相关联
sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib

现在通过finder启动...

详细说明:

rJava load error in RStudio/R after "upgrading" to OSX Yosemite