1

I'm new to R and shiny.

I setup a server and it mostly works, but R code that references the boto3 library fails with

"ModuleNotFoundError: No module named 'boto3'"

However, if I add this code at the top of the file:

library(reticulate)

use_condaenv("/home/ubuntu/anaconda3/envs/python_3x_nix")

Then, it works.

Even more confusing - once it works, I can remove those two lines and it continues to work for a while. Then, I suppose some kind of context object gets flushed and the errors come back.

So it would seem that the issue is just getting R to run with the correct conda environment (which I setup through conda externally) by default.

Can anyone tell me whether this is possible, and if so, then how?

divibisan
  • 11,659
  • 11
  • 40
  • 58
Zack
  • 301
  • 1
  • 4
  • 9
  • I'm seeing some posts that indicate I have to create my R environment from within my conda environment, so in this case I would be running R from /home/ubuntu/anaconda3/envs/python_3x_nix/ Is that correct? – Zack Jan 14 '22 at 17:29
  • Ping me back if that duplicate doesn't work for you and I can reopen. But mainly, you can set the RETICULATE_PYTHON variable in your .Rprofile and that will then define the default Python without having to set it each time. As for Conda R environments - no that doesn't sound right; native R installs should work fine with Conda Python environments. – merv Jan 14 '22 at 21:34
  • 1
    I had actually tried updating the .Rprofile file unsuccessfully, but I wrestled with it and the subtle difference is that it needs to point all the way to /bin/python: Sys.setenv(RETICULATE_PYTHON="/home/ubuntu/anaconda3/envs/python_3x_nix/bin/python") This works! – Zack Jan 17 '22 at 13:30

0 Answers0