Not my area of expertise, so apologies in advance. I am trying to run a command through system2() in R
The "planet" command (python program) works fine when typed directly in CMD:
F:\>planet --version
>1.5.2
However, I can't get it to recognize the command via system2() in either R or RStudio:
my_command <- "planet"
my_args <- " --version"
system2(command=my_command, args=my_args, stdout=TRUE)
>Error in system2(command = my_command, args = my_args, stdout = TRUE) :
'"planet"' not found
I read elsewhere that sometimes system() and system2() work in mysterious ways compared to shell(). So I also tried:
my_command <- "C:\\WINDOWS\\system32\\cmd.exe"
my_args <- "planet --version"
system2(command=my_command, args=my_args, stdout=TRUE)
>[1] "Microsoft Windows [Version 10.0.22621.1265]" "(c) Microsoft Corporation. All rights reserved."
[3] "" "C:\\Users\\alonzo\\Documents>"
Warning message:
In readLines(rf) :
incomplete final line found on 'C:\Users\alonzo\AppData\Local\Temp\Rtmpi0YeU3\file62084c285bff'
Any advice? I believe this all used to work fine on a different computer. I just installed Python and "planet" on this computer so maybe there is a PATH issue but it's not clear to me. Thank you.