I would like to import a python file and then use a function within that python file; but it does not work (it only work for source_python). Is it suppose to be this way? What is the difference?
As I am experiencing some problems with source_python, I would rather use import() if possible.
In python file called the_py_module.py includes this code:
def f1():
return "f one"
def f2():
return "f two"
R script
# Trying to import the python file, which appear to work:
reticulate::import("the_py_module")
Gives this output:
Module(the_py_module)
# But when calling the function:
f1()
I get error saying:
Error in f1() : could not find function "f1"
This works in the R script though.
reticulate::source_python("the_py_module.py")
f1()