首页 > 其他分享 >解决Pycharm配置R语言环境报错RWrapper terminated, exitcode: 127

解决Pycharm配置R语言环境报错RWrapper terminated, exitcode: 127

时间:2024-07-06 17:53:58浏览次数:15  
标签:terminated License GNU RWrapper General program 报错 home Public

问题

解决Pycharm配置R语言环境报错RWrapper terminated, exitcode: 127 error while loading shared libraries: libR.so: site:stackoverflow.com

解决方案

1. 打开GetEnvVars.R文件

打开 C:\Users\UserName\AppData\Roaming\JetBrains\PyCharm版本号\plugins\r-plugin\R\目录下的GetEnvVars.R文件。

  • 注:上面的UserName和PyCharm版本号按实际情况查找,如果没有找到,看下PyCharm的安装目录有没有...\plugins\r-plugin\R\GetEnvVars.R文件,不同版本路径可能有所区别

2.1 R版本大于3

如果R版本大于等于3,将内容替换成文件GetEnvVars.R的内容替换成:

#  Rkernel is an execution kernel for R interpreter
#  Copyright (C) 2019 JetBrains s.r.o.
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <https:#www.gnu.org/licenses/>.

getLDLibraryPath <- function() {

  sysinf <- Sys.info()

  if (sysinf['sysname'] == "Darwin") Sys.getenv("DYLD_FALLBACK_LIBRARY_PATH")
  else if (tolower(sysinf['sysname']) == "linux") {
    if(Sys.getenv("LDLIBRARY_PATH") == "") {
      sessinf <- sessionInfo()
      interpreter_lib_dir <- dirname(sessinf$BLAS)
      paste(interpreter_lib_dir, paste0(interpreter_lib_dir, "/R/lib"), sep = ":")
    } else {
      Sys.getenv("LDLIBRARY_PATH")
    }
  }
  else ""
}

cat(">>>RPLUGIN>>>")
cat(R.home(), R.home('share'), R.home('include'), R.home('doc'), Sys.getenv("PATH"), getLDLibraryPath(), sep = '\n')
cat("<<<RPLUGIN<<<")

2.2 R版本低于3

如果R版本低于3,将内容替换成文件GetEnvVars.R的内容替换成:

#  Rkernel is an execution kernel for R interpreter
#  Copyright (C) 2019 JetBrains s.r.o.
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <https:#www.gnu.org/licenses/>.

getLDLibraryPath <- function() {

  sysinf <- Sys.info()

  if (sysinf['sysname'] == "Darwin") Sys.getenv("DYLD_FALLBACK_LIBRARY_PATH")
  else if (tolower(sysinf['sysname']) == "linux") {
    if(Sys.getenv("LDLIBRARY_PATH") == "") {
      sessinf <- sessionInfo()
      interpreter_lib_dir <- dirname(sessinf$BLAS)
      if (R.version$major <= 3)
  	  	paste(dirname(dirname(interpreter_lib_dir)), interpreter_lib_dir, sep=':')
	  else if (R.version$major > 3)
      	paste(interpreter_lib_dir, paste0(interpreter_lib_dir, "/R/lib"), sep = ":")
	  else 
	  	""
    } else {
      Sys.getenv("LDLIBRARY_PATH")
    }
  }
  else ""
}

cat(">>>RPLUGIN>>>")
cat(R.home(), R.home('share'), R.home('include'), R.home('doc'), Sys.getenv("PATH"), getLDLibraryPath(), sep = '\n')
cat("<<<RPLUGIN<<<")

其他可能的原因

如果上面的方案没有解决,可以尝试下面的解决方案:

  1. 如果是从源码编译安装的,自编译的时候未使用该--enable-R-shlib选项编译 R。(源地址)
    安装教程:Linux下R安装配置以及工具包安装方式

标签:terminated,License,GNU,RWrapper,General,program,报错,home,Public
From: https://www.cnblogs.com/kingwz/p/18287527

相关文章