0

我正在尝试在 macOS High Sierra 版本 10.13.6 下运行的 Macbook Pro(2011 年末)上使用 R 中的 tm 包。tm 包已安装,但当我加载它时,我收到以下错误消息

Error: package or namespace load failed for ‘tm’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 there is no package called ‘slam’

然后我尝试安装 slam 并得到了这个:


  There is a binary version available but the source
  version is later:
     binary source needs_compilation
slam 0.1-45 0.1-46              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) y
installing the source package ‘slam’

trying URL 'https://cran.rstudio.com/src/contrib/slam_0.1-46.tar.gz'
Content type 'application/x-gzip' length 53515 bytes (52 KB)
==================================================
downloaded 52 KB

* installing *source* package ‘slam’ ...
** package ‘slam’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c apply.c -o apply.o
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c dll.c -o dll.o
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c grouped.c -o grouped.o
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c sparse.c -o sparse.o
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c util.c -o util.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o slam.so apply.o dll.o grouped.o sparse.o util.o -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [slam.so] Error 1
ERROR: compilation failed for package ‘slam’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/slam’
Warning in install.packages :
  installation of package ‘slam’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/zq/lzsw_rp15sj3wtfvb3r0kksc0000gn/T/RtmpX95gez/downloaded_packages’```
Can anyone please help me fix this?
Thanks!
4

1 回答 1

0

我今天遇到了完全相同的问题。我正在使用 macOS Mojave (10.14.6) 的 Mac Book Pro 上运行 R 3.6.1(和你一样),并且我有相同的错误消息。

我从这里尝试了一些答案: 安装 TM 包时无法使用依赖项 'slam'

通过尝试:

install.packages("NLP", dependencies = TRUE)
install.packages("tm", dependencies = TRUE)

......但没有快乐。

所以我去了这里: https://cran.r-project.org/web/packages/slam/index.html 并下载slam_0.1-45.tgz到我的下载文件夹然后直接从那里安装,使用:

install.packages("~/Downloads/slam_0.1-45.tgz", repos = NULL, type = .Platform$pkgType)

现在似乎可以很好地安装 tm 包。

于 2019-11-05T19:52:07.717 回答