Easy if you know how.
We are living in a time of interconnectivity, and barely a day goes by when I don’t use the scripting language R in a more or less intricate pipeline. Often I have R call out to the interpreted programming language Python or the system shell to run a third-party executable (see the pipeline P2C2M as an example). In such situations it is essential that R and Python work together seamlessly.
To ensure inter-operability, it is important for each scripting language to call the correct version of the other. To do that, the setting of “default versions” is usually the way to go. But how do you set the default version of Python to be called by R?
In Linux:
echo 'alias python=python2.7' >> ~/.bashrc
In MacOS (assuming that your Python version of choice resides in /usr/local/bin/):
echo 'Sys.setenv(PATH = paste("/usr/local/bin", Sys.getenv("PATH"), sep=":"))' >> /path_to_R/.Rprofile
Upon setting the default version as shown above, it is important that you re-compile the R package with which you call Python (e.g., rPython) from source and re-install it.
Thanks go to my colleague Katie E. for sharing the above strategy necessary under MacOS.