加载 gdata 包时如何修复 Perl 警告消息? [英] How to fix Perl warning message when loading gdata package?

查看:28
本文介绍了加载 gdata 包时如何修复 Perl 警告消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've updated Strawberry Perl 64-bit 5.30.2001 and the gdata package. Now, when loading library(gdata) I always get this warning messages which appear to be related to 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这个我需要的函数好像运行的还不错,只是每次用的时候都会提示警告.

However, read.xls, the function I need, seems to run well, except that the warning is repeated every time I use it.

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().

I'm not sure how to deal with this warning because it says nothing to me, I could probably just ignore it and wrap a suppressWarnings() around it.

尽管如此,有人知道解决这个问题的方法吗?我通过谷歌搜索找不到任何东西,不知道从哪里开始,也不知道到底出了什么问题.

Nevertheless, does anybody know a way to fix this? I couldn't find anything by googling and don't know where to start and what's actually wrong.

> 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 和 Strawberry Perl 版本中遇到了同样的问题.我终于找到了这个答案到一个不同(但相关)的问题.根据那里的建议,我在 elevated 命令提示符下运行了以下命令:

I had the same issue with a freshly installed version of R, gdata and Strawberry Perl. I finally found this answer to a different (but related) question. Adapting the suggestion there, I ran the following on an elevated command promt:

FTYPE perl=C:\Strawberry\perl\bin\perl.exe %1 %*

这为我解决了这个问题——但是:我不确定像这样设置 FTYPE 是否会产生任何不需要的副作用.所以要小心.

This solved the issue for me – however: I am not sure if setting the FTYPE like this might have any unwanted side effects. So be careful.

更新:上面的命令确实抑制了警告ftype perl' has status 2";对我来说,但 gdata 仍然有问题:

Update: The command above did suppress the warning "ftype perl' had status 2" for me, but gdata still had issues:

gdata:无法加载 read.xls() 所需的 perl 库gdata:支持XLSX"(Excel 2007+)文件.

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

gdata:运行函数installXLSXsupport()"gdata:自动下载安装perlgdata:支持 Excel XLS 和 XLSX 格式所需的库.

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

但是,installXLSXsupport() 失败并显示一条不明确的错误消息.

However, installXLSXsupport() failed with an unspecific error message.

然后我跑了

Sys.which("perl")
                              perl 
"C:\\rtools40\\usr\\bin\\perl.exe" 

并意识到 RTools 的 Perl 版本优先于我的 Strawberry Perl 安装 - 显然 gdata 并不喜欢"我的 Strawberry Perl 安装.那个 Perl 版本.

and realized that the Perl version from RTools takes precedence over my Strawberry Perl installation – and apparently gdata does not "like" that Perl version.

因此,我决定通过更改我的 .Renviron 文件 (usethis::edit_r_e​​nviron()) 来让 Strawberry Perl 优先于 RTools:

Therefore, I decided to give Strawberry Perl precedence over RTools by changing my .Renviron file (usethis::edit_r_environ()):

PATH="${RTOOLS40_HOME}\usr\bin;${PATH}" # old
PATH="${PATH};${RTOOLS40_HOME}\usr\bin" # new

同样,我不完全确定这个可能有什么后果,但它为我修复了gdata.也许单独调整 PATH 也可以解决问题(没有我首先制作的 ftype 特技),但我不能再测试了.

Again, I'm not entirely sure what ramifications this might have, but it fixed gdata for me. Maybe adjusting the PATH alone would also have done the trick (without the ftype stunt I made first), but I cannot test this anymore.

我的推荐:

  1. 先调整PATH.
  2. 如果 gdata 仍然抱怨 ftype,请设置 ftype.
  1. Adjust the PATH first.
  2. If gdata still complains about the ftype, set the ftype.

这篇关于加载 gdata 包时如何修复 Perl 警告消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆