What worked for me was first installing the python customLibrary via the python command line interface.
Second, in my R project folder I specified the python function in a file customLibrary.py which specifies import as first line, such as:
import customLibrary as CL
def custoFunction(path):
A = CL.test(path)
return(A)
Third, I call the function from R via standard reticulate::source_python("customLibrary.py")
implementation (You may need to check whether your directory-path is correct via R command getwd()
.)
It may be helpful to start with small steps to narrow down the issue:
- just write a simple function, such as "addThree" that is essentially
y = x + 3
etc.
- try to execute it in python
- try to execute if from R
If both works you can try to do the same thing with the custom library.