No module named 'rpytools' when using reticulate via source

809 Views Asked by At

I have an R script that calls a Python script through the reticulate package. When I run this manually from R Studio, the script works perfectly. However, when I schedule through ScheduleR to run automatically at set times, I receive an error stating there is no module named 'rpytools,' which prevents the Python script from executing. Additionally, I have no errors with other R scripts operating through the task scheduler. EDIT: This same error occurs when I source the code through R Studio but not when the code is otherwise run.

Error in py_module_import(module, convert = convert) : 
ModuleNotFoundError: No module named 'rpytools'
Calls: import ... ensure_python_initialized -> remap_output_streams -> import -> py_module_import
Execution halted

Help would be appreciated. For reference, I am using RStudio v 1.4.1103 and R v 4.0.3 and Python 3.6.12. Please let me know what other details would be helpful.

Update: I initially thought this might be caused by the task scheduler, but it appears to be an error thrown by reticulate when sourcing the code. Oddly, it throws the error on a new session the first time it is sourced, but runs fine on the second source.

0

There are 0 best solutions below