I am having problems with loading modules in a python script which I am calling via reticulate
.
My file-structure basically looks like this:
Rscript.R
library(reticulate)
py_run_file("python1.py")
python1.py
print("test1")
import python2 as p2
p2.run_test(123)
python2.py
def run_test(x):
print("inside p2-run_test()")
print(x)
Now if I am running Rscript.R
, it works fine, but changing python2.py
like this (adding a new function):
python2.py
def run_test(x):
print("inside p2-run_test()")
print(x)
def run_test2(x):
print("inside p2-run_test2()")
print(x)
and python1.py
like this (calling said function):
python1.py
print("test1")
import python2 as p2
p2.run_test2(123)
i get the following error:
test1
Error in py_run_file_impl(file, local, convert) :
AttributeError: 'module' object has no attribute 'run_test2'
Can anybody help me here how I can fix this?