我在 R 中加载库 soiltexture 时遇到问题

I am having a problem loading library soiltexture in R

我在 MacOS 11.3.1

上加载 R 版本 4.1.1 中的 soiltexture 包时遇到问题

我试过两种安装方式:

  1. install.packages(soiltexture)

安装没有错误

2.

install.packages(
pkgs = "soiltexture",
repos = "http://R-Forge.R-project.org"
) 

包错误 soiltexture 不适用于此版本的 R



当我只使用第一个选项安装时 库(土壤纹理)我得到这个错误
Error: package or namespace load failed for ‘soiltexture’: .onLoad failed in loadNamespace() for 'tcltk', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared object '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/tcltk/libs/tcltk.so': dlopen(/Library/Frameworks/R.framework/Versions/4.1/Resources/library/tcltk/libs/tcltk.so, 10): Library not loaded: /opt/X11/lib/libX11.6.dylib Referenced from: /Library/Frameworks/R.framework/Versions/4.1/Resources/library/tcltk/libs/tcltk.so Reason: image not found

我看到“tcltk”是一个基础包,所以我不确定从这里到哪里去。

也试过

install.packages("devtools")
devtools::install_github("julienmoeys/soiltexture/pkg/soiltexture")

此信息和错误:

Downloading GitHub repo julienmoeys/soiltexture@HEAD
✓  checking for file ‘/private/var/folders/bq/x1vhzkf57p3fd9npyyb9wvlm0000gn/T/Rtmp1BYNgF/remotes14af6685ccbb4/julienmoeys-soiltexture-7586a8b/pkg/soiltexture/DESCRIPTION’ ...
─  preparing ‘soiltexture’:
✓  checking DESCRIPTION meta-information ...
─  installing the package to process help pages
         -----------------------------------
─  installing *source* package ‘soiltexture’ ...
   ** using staged installation
   ** R
   ** inst
   ** byte-compile and prepare package for lazy loading
   xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
   Warning in system2("/usr/bin/otool", c("-L", shQuote(DSO)), stdout = TRUE) :
     running command ''/usr/bin/otool' -L '/Library/Frameworks/R.framework/Resources/library/tcltk/libs//tcltk.so'' had status 1
   Error: .onLoad failed in loadNamespace() for 'tcltk', details:
     call: dyn.load(file, DLLpath = DLLpath, ...)
     error: unable to load shared object '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/tcltk/libs/tcltk.so':
     dlopen(/Library/Frameworks/R.framework/Versions/4.1/Resources/library/tcltk/libs/tcltk.so, 10): Library not loaded: /opt/X11/lib/libX11.6.dylib
     Referenced from: /Library/Frameworks/R.framework/Versions/4.1/Resources/library/tcltk/libs/tcltk.so
     Reason: image not found
   Execution halted
   ERROR: lazy loading failed for package ‘soiltexture’
─  removing ‘/private/var/folders/bq/x1vhzkf57p3fd9npyyb9wvlm0000gn/T/RtmpdN89vG/Rinst1523015dba5c8/soiltexture’
         -----------------------------------
   ERROR: package installation failed

Error: Failed to install 'soiltexture' from GitHub: System command 'R' failed, exit status: 1, stdout + stderr: E> * checking for file ‘/private/var/folders/bq/x1vhzkf57p3fd9npyyb9wvlm0000gn/T/Rtmp1BYNgF/remotes14af6685ccbb4/julienmoeys-soiltexture-7586a8b/pkg/soiltexture/DESCRIPTION’ ... OK E> * preparing ‘soiltexture’: E> * checking DESCRIPTION meta-information ... OK E> * installing the package to process help pages E> ----------------------------------- E> * installing *source* package ‘soiltexture’ ... E> ** using staged installation E> ** R E> ** inst E> ** byte-compile and prepare package for lazy loading E> xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun E> Warning in system2("/usr/bin/otool", c("-L", shQuote(DSO)), stdout = TRUE) : E> running command ''/usr/bin/otool' -L '/Library/Frameworks/R.framework/Resources/library/tcltk/libs//tcltk.so'' had status

感谢所有帮助!

在 python 流行之前,

tcl/tk 是一种流行的 UI 脚本语言。

查看您的错误,我假设您在 Windows。该软件包缺少 tcl 共享库。看这里 - https://wiki.tcl-lang.org/page/How+to+compile+Tcl+and+related+C+extensions+on+Windows

步骤 1 - tcl/tk 在没有 R 的情况下工作:找到 tcltk 的 wish.exe 并启动它。有用吗?

步骤2 - 检查环境变量的值MY_TCLTK 是否指向Tcl/Tk的bin文件夹?如果不是:修复它。

如果未定义:将值设置为 bin 文件夹。

看这里 - https://mirrors.dotsrc.org/cran/bin/windows/base/rw-FAQ.html#Package-TclTk-does-not-work_002e