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
相关产品推荐
相关产品推荐

