You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法安装R语言psych包的问题及已尝试方案求助

安装R包psych和ggplot2失败的问题

错误详情

执行install.packages("psych")时返回以下错误:

install.packages("psych")
WARNING: Rtools is required to build R packages but no version of Rtools compatible with the currently running version of R was found. Note that the following incompatible version(s) of Rtools were found:

  - Rtools 3.2 (installed at c:\Rtools)

Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/

  There is a binary version available but the source version is later:
      binary source needs_compilation
psych  2.1.3  2.3.3             FALSE

installing the source package ‘psych’

trying URL 'https://cran.rstudio.com/src/contrib/psych_2.3.3.tar.gz'
Content type 'application/x-gzip' length 1588126 bytes (1.5 MB)
downloaded 1.5 MB

* installing *source* package 'psych' ...
** package 'psych' successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  there is no package called 'tmvnsim'
Calls: <Anonymous> ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
ERROR: lazy loading failed for package 'psych'
* removing 'C:/Users/the.user/Documents/R/R-3.6.2/library/psych'
Warning in install.packages :
  installation of package ‘psych’ had non-zero exit status

The downloaded source packages are in
    ‘C:\Users\the.user\AppData\Local\Temp\Rtmpm0Zlci\downloaded_packages’

调用library(psych)时的错误:

Error in library(psych) : there is no package called 'psych'

已尝试操作

  • 安装并运行Rtools33.exe、Rtools32.exe
  • 清理R环境,重启R会话
  • 退出并重启RStudio程序

系统与R版本信息

  • 操作系统:Windows 10 Enterprise 64位(x64处理器)
  • R版本信息:
$platform
[1] "i386-w64-mingw32"

$arch
[1] "i386"

$os
[1] "mingw32"

$system
[1] "i386, mingw32"

$status
[1] ""

$major
[1] "3"

$minor
[1] "6.2"

$year
[1] "2019"

$month
[1] "12"

$day
[1] "12"

$`svn rev`
[1] "77560"

$language
[1] "R"

$version.string
[1] "R version 3.6.2 (2019-12-12)"

$nickname
[1] "Dark and Stormy Night"

解决步骤

  1. 先安装依赖包tmvnsim
    错误日志明确提示缺少tmvnsim包,先手动安装:

    install.packages("tmvnsim")
    

    安装完成后再尝试安装psych:

    install.packages("psych")
    
  2. 匹配Rtools版本
    R 3.6.x对应的Rtools版本是Rtools35,卸载已安装的Rtools32/33,安装对应版本的Rtools,安装时勾选“Add Rtools to system PATH”选项。

  3. 优先安装二进制包
    由于R版本较老,直接指定安装二进制版本的包,避免编译源码:

    install.packages("psych", type = "binary")
    install.packages("ggplot2", type = "binary")
    
  4. 检查R架构与系统匹配
    当前系统是64位,但R是32位版本(arch显示i386),可考虑安装64位的R 3.6.x版本,避免架构不兼容问题。


内容的提问来源于stack exchange,提问作者Josh Strauss

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 18:22:49