1

I am using reticulate to source a function from a python file using reticulate::source_python(). However, this prints texts (warnings) in red in the RStudio console the first time I source it in a session; and I would like to silence or suppress it. I've tried several ways but none work:

 # Attempt 1
  suppressWarnings("My source_python(path_to_function)")
  
  # Attempt 2
  suppressMessages("My source_python(path_to_function)")
  
  # Attempt 3
  capture.output("My source_python(path_to_function)")
  
  # Attempt 4
  invisible("My source_python(path_to_function)")
  
  # Attempt 5
  invisible(capture.output("My source_python(path_to_function)"))
  
  # Attempt 6
  zz <- file("test.txt", open = "wt")
  sink(zz ,type = "output")
  sink(zz, type = "message")
  print("using print")
  cat("using cat\n")
  message("using message")
  warning("using warning")
  "My source_python(path_to_function)"
  #and to close connections
  sink()
  sink()
  file.show("test.txt")

Is there any other way that I could try. Thanks in advance.

Oscar Kjell
  • 1,599
  • 10
  • 32

0 Answers0