如何将Radian作为R的代码终端进行故障排除

发布于 2025-01-25 23:03:10 字数 492 浏览 1 评论 0 原文

radian(对于r)不是在VS代码中的终端启动时

短暂显示的扩展错误消息(来自Python异常?)

The terminal process 
"c:\Program Files\Python310\Scripts\radian.exe '--nosave', '--no-restore', '--r-binary="C:/program files/R/R-4.1.3/bin/x64/R.exe"'"
terminated with code: 1.

, 进入VS代码终端 - 然后Radian开始得很好。 (在命令提示符终端或git bash终端中工作。)

  1. 如何停止终端关闭错误,以便可以读取Python异常日志?

  2. 问题知道吗? (我怀疑它与VS代码环境有关。)

注意:我有 terminal.integrated.inheritenv:true

radian (for R) is not starting as terminal in VS Code

There is an extended error message (from python exception?) that is displayed briefly, then the terminal closes and error message comes up:

The terminal process 
"c:\Program Files\Python310\Scripts\radian.exe '--nosave', '--no-restore', '--r-binary="C:/program files/R/R-4.1.3/bin/x64/R.exe"'"
terminated with code: 1.

If I cut-n-paste the command line into a VS Code terminal - then radian starts perfectly fine. (Works in both a command prompt terminal or a git bash terminal.)

  1. How do I stop the terminal closing on error, so that the python exception log can be read ?

  2. Is the problem known ? (I suspect its related to VS Code Environment.)

Note: I have terminal.integrated.inheritEnv: true

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

-残月青衣踏尘吟 2025-02-01 23:03:10

查看您上面的设置 - 是否是使用路径中的前向斜杠而不是后斜线设置 r -binary 选项标志? ie flag 应该 be:

- r-binary =“ c:\ program Files \ r \ r \ r-4.1.3 \ bin \ x64 \ r.exe”

而不是您现在拥有的内容,即:

-r-binary =“ C:/Program Files/r/r-4.1.3/bin/x64/r.exe”

Looking at the settings that you have above - is it that your r-binary option flag is set using forward slashes in your path instead of backslashes? i.e. the flag should be:

--r-binary="C:\program files\R\R-4.1.3\bin\x64\R.exe"

instead of what you have right now, which is:

--r-binary="C:/program files/R/R-4.1.3/bin/x64/R.exe"

潦草背影 2025-02-01 23:03:10

假设您的radian配置是正确的,则使用“ r.rterm.windows”:,您会收到以下错误:

终端过程[“通往radian的路径”]' - nosave',' - no-Restore'用代码终止:1。

这是因为Radian无法知道系统在系统上的位置。设置“ r.rpath.windows”:参数是没有用的,因为这仅在将R集成终端设置为默认的VS代码终端时才有用。解决方案是指向R安装所在的Radian。为此,您有三种方法。

  1. 使用名称R_HOME和R安装路径创建一个新的系统环境变量。要执行此操作:遵循以下顺序:CTRL+I/SYSTEM/aid Awod/,然后在“设备规格”部分中单击“高级系统设置”,然后单击“ EnviroMantal变量”,然后在“系统变量”部分中单击“新”,“新”,然后在没有引号的“变量名称”中,在“变量值”中键入r安装路径中,在我的情况下,它是“ c:\ program files \ r \ r-r-4.4.4.4.1”,没有引号。始终记住重新启动计算机,以使新环境变量与系统集成。

  2. 第二种方法是配置VS代码.json文件以指定R_HOME环境变量。这是一个示例,说明配置在Radian终端和R_HOME系统环境变量中的外观(请记住,路径会根据您的安装和系统而变化):

    {
    “ R.RterM.Windows”:
    “ c:\ users \ dioni \ appdata \ local \ program \ python \ python310 \ scripts \ radian.exe”,
    “ terminal.integrated.env.windows”:{
    “ R_HOME”:“ C:\ Program Files \ r \ r-4.4.1”
    }
    }

  3. 第三种方法是在使用R代码运行脚本之前进行手动配置。为此,打开VS代码中的新终端,它可以是内置的Windows CMD终端或PowerShell并运行以下内容:对于CMD 设置R_HOME =%programFiles%\ r \ r \ r-r-4.4.1 如果在“程序文件”中安装了R,则运行 Radian 。对于PowerShell运行 Env:R_HOME =“ $ env:programFiles \ r \ r-4.4.4.1” ,然后运行 radian 。这样,您将在VS代码中从CMD或PowerShell启动Radian。但是,VS代码仍然不会将Radian用作默认R终端,因此请转到VS代码中安装的R插件设置,并启用“为所有命令使用Active Terminal,而不是创建新的R终端”。使用主动终端“部分。


您可以选择最适合您工作流程的方法。

Assuming your Radian configuration is correct as the default terminal for R in VS Code, using "r.rterm.windows":, and you get the following error:

the terminal process ["path to radian"] '--nosave', '--no-restore' terminated with code: 1.

this is because Radian has no way of knowing where the R installation is on the system. It is not useful to set the "r.rpath.windows": parameter as this is only useful when setting the R integrated terminal as the default VS Code terminal. The solution is to specify to Radian where the R installation is located. For this you have three approaches.

  1. Create a new system environment variable with the name R_HOME and the R installation path. To do this follow the sequence: Ctrl+i/system/about/, then in the device specifications section click on "Advanced system settings", then "Enviromental Variables", then in the "System variables" section click on "New", then in "Variable name" type "R_HOME" without quotes, in "Variable value" type the R installation path, in my case it is "C:\Program Files\R\R-4.4.1" without quotes. Always remember to restart the computer so that the new environment variable is integrated with the system.

  2. The second approach is to configure the VS Code .json file to specify the R_HOME environment variable. Here is an example of how the configuration should look in the Radian terminal and the R_HOME system environment variable (remember the paths will vary depending on your installation and system):

    {
    "r.rterm.windows":
    "C:\Users\dioni\AppData\Local\Programs\ Python\Python310\Scripts\radian.exe",
    "terminal.integrated.env.windows": {
    "R_HOME": "C:\Program Files\R\R-4.4.1"
    }
    }

  3. The third approach is to do a manual configuration before running your script with R code. To do this, open a new terminal in VS Code, it can be the built-in windows CMD terminal or PowerShell and run the following: for CMD set R_HOME=%PROGRAMFILES%\R\R-4.4.1 if R is installed in "programs files", then run radian. for PowerShell run env:R_HOME="$env:PROGRAMFILES\R\R-4.4.1", then run radian. With that you will be starting radian as a terminal from cmd or PowerShell in VS Code. However, VS Code will still not use radian as the default R terminal, so go to the R plugin settings installed in VS Code and enable "Use active terminal for all commands, rather than creating a new R terminal" in the "R: Always Use Active Terminal" section.

You can choose the approach that best suits your workflow.

耀眼的星火 2025-02-01 23:03:10

此博客文章()提出了解决' - nosave',' - no-restore',' - r-binary'通过添加其他 r.rterm.option 列表:

{
  "r.bracketedPaste": true,
  "r.rpath.mac": "/usr/local/bin/R",
  "r.rterm.mac": "/Library/Frameworks/Python.framework/Versions/3.11/bin/radian",
  "r.rterm.option": [
    "--no-save",
    "--no-restore",
    "--r-binary=/usr/local/bin/R"
  ]
}

r.rterm.mac 的路径可以通过运行可以找到 我的计算机(Mac)上的错误(Mac)。终端中的radian 。同样, r.rpath.mac 的路径可以通过 r 找到。

This blog post (https://jimgar.github.io/posts/vs-code-macos-r/post.html) presents a solution that resolved the '--nosave', '--no-restore', '--r-binary' error on my machine (mac) by adding an additional r.rterm.option list:

{
  "r.bracketedPaste": true,
  "r.rpath.mac": "/usr/local/bin/R",
  "r.rterm.mac": "/Library/Frameworks/Python.framework/Versions/3.11/bin/radian",
  "r.rterm.option": [
    "--no-save",
    "--no-restore",
    "--r-binary=/usr/local/bin/R"
  ]
}

The path for r.rterm.mac can be found by running which radian in the terminal. Similarly, the path for r.rpath.mac can be found by with which R.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文