Using a custom python function in a r package

Hi,

I am working on implementing a new feature for my refinitiv package and I want to use a custom python function. However I don't want to create a global variable in my r package as the cran check does not like this.

reticulate::import_from_path( module = "refinitiv_utils.py"
                            ,  path = system.file("python/refinitiv_utils.py", package = "Refinitiv")
                            ,  delay_load = F, convert = F
                            )

fails with the following warning:

Error in py_module_import(module, convert = convert) : 
  ModuleNotFoundError: No module named 'refinitiv_utils'

however if I execute:

split_tupple_list <<- reticulate::source_python(system.file("python/refinitiv_utils.py"
                                                           , package = "Refinitiv"))

the function works without any issues.

the contents of the function refinitiv_utils.py:

def split_tupple_list(x):
  return_list = [item[0] for item in x]
  return return_list

Any advice pls?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.