I created the following python script in RStudio
import numpy as np
def test_function(a, b):
print("We are in the function")
return (a+b)
test_function(7,4)
line import numpy as np
runs fine. It invokes python in console >>>
line with function definition leaves ...
. It looks like it is not completely executed.
line test_function(7,4)
generates
SyntaxError: unexpected EOF while parsing (<string>, line 1)
We are in the function
11
What part of EOF am I missing?
Also, it seems like this script is using reticulate installation:
reticulate::repl_python()
... AppData/Local/r-miniconda/envs/r-reticulate/python.exe.
How can I tell it to use my conda virtual env. In reticulate, I would use something like reticulate::use_condaenv("env1")
, but how can do it here?
question from:
https://stackoverflow.com/questions/65893565/running-python-function-in-rstudio-eof-error-in-function-definition 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…