问题
I want to execute python with R but
> system2('python2', args = c('-c', 'print', 'hello'), stdout = TRUE)
[1] ""
prints ""
instead of hello
with python2.
Then again
> system2('python3', args = c('-c', 'print("hello")'), stdout = TRUE, stderr = TRUE)
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `'python3' -c print("hello") 2>&1'
character(0)
attr(,"status")
[1] 2
Warning message:
running command ''python3' -c print("hello") 2>&1' had status 2
prints a lot of warnings. The intended output was hello
.
How to print hello with python2/python3 inside R using system2?
来源:https://stackoverflow.com/questions/45426902/system2-to-call-python2-and-python3-inside-r