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

VSCode运行R遇“R解释器未关联”问题求助

VSCode运行R时提示“R interpreter not attached”无法执行代码的问题

已安装环境

  • R 4.3.1
  • VSCode的R运行插件

问题现象

打开新R文件时会自动启动新的R终端,但选中代码点击运行后没有任何执行反应,VSCode提示*“R interpreter not attached”*,找不到关联R解释器的方法。尝试在终端下拉菜单中选择R终端,问题依然存在。

可以在PowerShell中进入R.exe所在目录,通过以下命令正常执行R脚本:

.\Rscript.exe "C:\Users\Path\to\file\first_R.r"

已尝试的解决方法

  • 重新安装VSCode的R插件
  • 切换使用R终端
  • 点击“关联R终端”选项
  • 参考Stack Overflow上两个匹配问题的解决方案(包括配置"r.rterm.windows"、设置集成终端),但均无效果

当前settings.json配置

{
    "r.plot.defaults.colorTheme": "vscode",
    "r.rpath.windows": "C:\\Program Files\\R\\R-4.3.1\\bin\\R.exe",
    "r.rterm.windows": "C:\\Program Files\\R\\R-4.3.1\\bin\\R.exe",
    "r.alwaysUseActiveTerminal": true,
    "r.rterm.option": [
        "--no-save",
        "--no-restore",
        "--r-binary=C:\\Program Files\\R\\R-4.3.1\\bin\\R.exe"
    ],
    "files.associations": {
        "*.r": "r"
    },
    "terminal.integrated.profiles.windows": {
        "PowerShell": {
            "source": "PowerShell",
            "icon": "terminal-powershell"
        },
        "Command Prompt": {
            "path": [
               "${env:windir}\\Sysnative\\cmd.exe",
               "${env:windir}\\System32\\cmd.exe"
             ],
             "args": [],
             "icon": "terminal-cmd"
        },
        "R": {
            "path": [
                "C:\\Program Files\\R\\R-4.3.1\\bin\\R.exe"
            ]
        },
     },  
}

注:无管理员权限设置PATH环境变量。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 12:52:33