r - 加载 gdata 包时如何修复 Perl 警告消息?

标签 r windows perl xls gdata

我已经更新了 Strawberry Perl 64-bit 5.30.2001gdata 包。现在,在加载 library(gdata) 时,我总是收到这些似乎与 Perl 相关的警告消息。

suppressPackageStartupMessages(library(gdata))
# Warning messages:
#   1: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
#     running command 'C:\Windows\system32\cmd.exe /c ftype perl' had status 2
#   2: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
#     running command 'C:\Windows\system32\cmd.exe /c ftype perl' had status 2
但是,我需要的函数 read.xls 似乎运行良好,只是每次使用时都会重复警告。
read.xls("http://file-examples-com.github.io/uploads/2017/02/file_example_XLS_10.xls")
# trying URL 'http://file-examples-com.github.io/uploads/2017/02/file_example_XLS_10.xls'
# Content type 'application/vnd.ms-excel' length 8704 bytes
# downloaded 8704 bytes

#   X0 First.Name Last.Name Gender       Country Age       Date   Id
# 1  1      Dulce     Abril Female United States  32 15/10/2017 1562
# 2  2       Mara Hashimoto Female Great Britain  25 16/08/2016 1582
# 3  3     Philip      Gent   Male        France  36 21/05/2015 2587
# 4  4   Kathleen    Hanner Female United States  25 15/10/2017 3549
# 5  5    Nereida   Magwood Female United States  58 16/08/2016 2468
# 6  6     Gaston     Brumm   Male United States  24 21/05/2015 2554
# 7  7       Etta      Hurn Female Great Britain  56 15/10/2017 3598
# 8  8    Earlean    Melgar Female United States  27 16/08/2016 2456
# 9  9   Vincenza   Weiland Female United States  40 21/05/2015 6548
# Warning messages:
#   1: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
#     running command 'C:\Windows\system32\cmd.exe /c ftype perl' had status 2
#   2: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
#     running command 'C:\Windows\system32\cmd.exe /c ftype perl' had status 2
我不确定如何处理这个警告,因为它对我没有任何意义,我可能只是忽略它并在它周围包裹一个 suppressWarnings()
然而,有人知道解决这个问题的方法吗?我通过谷歌搜索找不到任何东西,不知道从哪里开始,也不知道到底出了什么问题。
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] gdata_2.18.0

loaded via a namespace (and not attached):
[1] compiler_4.0.2 tools_4.0.2    gtools_3.8.2  

最佳答案

我在新安装的 R 版本中遇到了同样的问题,gdata和草莓 Perl。终于找到this answer到一个不同(但相关)的问题。根据那里的建议,我在提升的命令提示符下运行了以下命令:

FTYPE perl=C:\Strawberry\perl\bin\perl.exe %1 %*
这为我解决了这个问题 - 但是:我不确定是否设置 FTYPE像这样可能会产生任何不需要的副作用。所以要小心。

更新:上面的命令确实抑制了我的警告“ftype perl' has status 2”,但是 gdata仍然有问题:

gdata: Unable to load perl libaries needed by read.xls() gdata: to support 'XLSX' (Excel 2007+) files.

gdata: Run the function 'installXLSXsupport()' gdata: to automatically download and install the perl gdata: libaries needed to support Excel XLS and XLSX formats.


然而,installXLSXsupport()失败并显示不明确的错误消息。
然后我跑了
Sys.which("perl")
                              perl 
"C:\\rtools40\\usr\\bin\\perl.exe" 
并意识到来自 RTools 的 Perl 版本优先于我的 Strawberry Perl 安装 - 显然是 gdata不“喜欢”那个 Perl 版本。
因此,我决定通过更改我的 .Renviron 来让 Strawberry Perl 优先于 RTools。文件 ( usethis::edit_r_environ() ):
PATH="${RTOOLS40_HOME}\usr\bin;${PATH}" # old
PATH="${PATH};${RTOOLS40_HOME}\usr\bin" # new
同样,我不完全确定这可能会产生什么后果,但它修复了 gdata为了我。
也许调整 PATH一个人也可以做到这一点(没有我先做的 ftype 特技),但我不能再测试了。
我推荐的是:
  • 调整 PATH第一的。
  • gdata还在提示ftype ,设置 ftype .
  • 关于r - 加载 gdata 包时如何修复 Perl 警告消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63411363/

    相关文章:

    r - 使用 dplyr 中的列表列函数进行变异

    R - 如何为 Shiny 的服务器设置 install.packages() 的路径? - Ubuntu

    c++ - 在 NONCLIENTMETRICS 中,状态字体、消息字体和标题字体之间有什么区别?

    perl - Spreadsheet::Read 的问题

    r - 对多个条件使用 if else 语句

    r - R中间隔不均匀的多个文件的分箱

    c++ - _T ("x") 没有按预期行事

    python - 为 Windows 构建 Vulkan 工具

    Perl Prove TAP::Harness color (color) 输出 windows (win32)

    linux - 使用 perl 连接 oracle 和 LDAP