Blog

Home | About | Archive | RSS

Getting Python and RStudio to work together

I ran into a strange problem today while attempting to use RStudio as my Python IDE. I don’t do all that much with Python, but since I work with data as part of my job, it’s inevitable that I’ll have to do some things with it (and I’m perfectly fine with that).

It’s always “just worked” before. Today I got a strange message when I tried to run a Python script:

Would you like to create a default python environment for the reticulate package? (Yes/no/cancel)

It was annoying because

It was a hopeless loop, because “no” was the only way to break out of it, but the message returned as soon as I tried to do anything with Python again. Some experimentation revealed that the solution is:

library(reticulate)
use_python("/usr/bin/python3")

The location in the last line is the location of the Python executable installed on my machine; it may be elsewhere on yours.



True minimal theme