作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我可以从终端运行 perl 脚本“myperlscript.pl”,没有任何问题。但是,如果我尝试从 RStudio 中运行相同的 perl 脚本,则会出现以下错误:
command <- "myperlscript.pl outputfile.txt"
system2('perl', command)
Can't locate Sort/Fields.pm in @INC (you may need to install the Sort::Fields module)
(@INC contains:
/Library/Perl/5.28/darwin-thread-multi-2level
/Library/Perl/5.28
/Network/Library/Perl/5.28/darwin-thread-multi-2level
/Network/Library/Perl/5.28
/Library/Perl/Updates/5.28.2
/System/Library/Perl/5.28/darwin-thread-multi-2level
/System/Library/Perl/5.28
/System/Library/Perl/Extras/5.28/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.28) at myperlscript.pl line 4.
BEGIN failed--compilation aborted at myperlscript.pl line 4.
我在/Users/admin/perl5/perlbrew/perls/5.26.2/lib/site_perl/5.26.2 中安装了 Sort::Fields 模块,并且使用终端可以正常工作,但 RStudio 中的 perl 似乎没有为 perl 模块索引该目录 - 我尝试将其添加到 @INC 但不知何故我无法让它工作......有什么想法或想法吗?非常感谢您的帮助!
祝你好,平子
最佳答案
您遇到的问题是您的 R 代码使用的是系统 perl (5.28),而不是您的 pelbrew perl (5.26.2)。
您需要执行 system2('perl', command)
调用才能使用 perlbrew perl 而不是系统 perl。
要在激活了 perlbrew perl 的 shell 中执行此操作,请输入 which perl
这将为您提供 pelbrew perl 的完整路径。
将此完整路径作为第一个参数传递给 system2(--result of 'which perl'--, command)
。
关于r - 如何从 R 运行带有特定模块的 perl 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65553325/
我是一名优秀的程序员,十分优秀!