I am helping to put together an ArcMap Toolbox, one component of which makes a system call to R's
Rscript command-line executable. Everything works nicely, except that while the call to
Rscript is being executed, a black Windows command line console opens up. (The console looks much like the one you get if you click the Windows Home button and then type
cmd and press return.)
To reproduce what I'm seeing, run the following code in ArcMap's Python Console (I'm using ArcMap 10.5.1.), replacing the path in that first line with the path to
Rscript on your own computer.
rscript = "C:/R/R-current/bin/Rscript.exe" rscript = rscript + ' --vanilla -e' rcall = rscript + """ "Sys.sleep(10)" """ rcall ## 'C:/R/R-3.1.2/bin/Rscript.exe --vanilla -e "Sys.sleep(10)" ' import subprocess subprocess.call(rcall)
Is there any way to get this (or some related call to R) to run without ArcMap opening up the distracting Windows cmd console?
(It may be worth mentioning that this behavior seems to be specific to ArcMap's Python console. Running the same Python commands from other Python IDE's (e.g. Visual Studio Code, Spyder) executes the R commands without opening up a Windows cmd console.)