1

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.

TylerH
  • 20,799
  • 66
  • 75
  • 101
DrSchuess
  • 11
  • 2
  • What program are you using? taskscheduleR, if so what user/role is taskscheduleR running as - you can check in Task Scheduler – GrahamA Feb 10 '21 at 15:32
  • Yes, I'm using taskscheduleR. If I understand you correctly, the user it assigns is my username. Additionally, and I'll edit the prompt to reflect, the same error is received when I I source the code from R Studio as opposed to run it. – DrSchuess Feb 10 '21 at 16:05
  • Looks to me like you need to point in your R script the correct path of the python environment which is used by reticulate. –  Feb 15 '21 at 12:38

0 Answers0