Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
312 views
in Technique[技术] by (71.8m points)

r - Running python function in RStudio - eof error in function definition

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...