安装R包ithir时遇spatstat未导出对象错误求助
解决ithir包安装失败的问题
错误详情
执行安装命令:
install.packages("ithir", repos="http://R-Forge.R-project.org")
触发如下错误:
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
Installing package into ‘C:/Users/cloud-user/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
installing the source package ‘ithir’trying URL 'http://R-Forge.R-project.org/src/contrib/ithir_1.0.tar.gz'
Content type 'application/x-gzip' length 4534681 bytes (4.3 MB)
downloaded 4.3 MB
- installing source package 'ithir' ...
** using staged installation
** R
** data
** byte-compile and prepare package for lazy loading
Error: objects 'ripras', 'as.ppp', 'delaunay' are not exported by 'namespace:spatstat'
Execution halted
ERROR: lazy loading failed for package 'ithir'- removing 'C:/Users/cloud-user/AppData/Local/R/win-library/4.2/ithir'
Warning in install.packages :
installation of package ‘ithir’ had non-zero exit status
问题根源
- Windows环境缺少编译R源包必需的Rtools工具;
- 当前安装的
spatstat包版本过高,新版本调整了函数结构,不再导出ripras、as.ppp、delaunay这几个对象,导致ithir包依赖失效。
解决方案
步骤1:安装Rtools
根据你的R版本(4.2.x)安装对应版本的Rtools,安装过程中务必勾选"Add Rtools to system PATH"选项,确保系统能识别编译工具。
步骤2:降级spatstat包
- 先卸载现有spatstat:
remove.packages("spatstat")
- 安装与ithir兼容的旧版spatstat(推荐1.64-1版本):
install.packages("spatstat", version="1.64-1", repos="https://cran.r-project.org")
- 重新安装ithir:
install.packages("ithir", repos="http://R-Forge.R-project.org")
备选方案:安装预编译二进制包
若编译源包仍有问题,可尝试寻找ithir的预编译二进制包,直接跳过编译步骤完成安装。
内容的提问来源于stack exchange,提问作者bidhan ghimire
相关产品推荐
相关产品推荐

