Integrating RStudio Workbench with reticulate to interface with Python#
These instructions describe how to use the
reticulate R package with RStudio to interface with Python.
Once you configure
reticulate with RStudio Workbench with an installation of Python, users will
be able to develop mixed R and Python content with Shiny apps, R Markdown
reports, and Plumber APIs that call out to Python code using the
RStudio uses the reticulate R package to interface with Python, and so RStudio's Python integration requires:
- Installation of Python 3.5, or newer
- The reticulate R package (1.20, or newer; as available from CRAN)
Step 1. Install Python for all users#
- First, follow the Install Python from Source instructions on the server with RStudio Workbench in a central location for all users (e.g.,
- Once you have completed the steps to Install Python from Source, continue to Step 2.
Step 2. Install
reticulate for all users#
reticulateR package for all users in the global R library.
For example, if R is installed in
/opt/R/3.7.7/, then you you can use the following command:Terminal
$ sudo /opt/R/3.7.7/bin/Rscript -e 'install.packages("reticulate")'
Step 3. Configure
reticulate with Python for all users#
RETICULATE_PYTHONenvironment variable for all RStudio Workbench users by putting the following line in the R session-specific profile script used by RStudio Workbench.
For example, if Python is installed in
/opt/python/3.7.7/, then you you can use the following configuration:File: /etc/rstudio/rsession-profile
Now, you are ready to develop Shiny apps, R Markdown, and Plumber APIs with Python/R in the RStudio IDE and RStudio Workbench using the
reticulate package per https://blog.rstudio.com/2018/10/09/rstudio-1-2-preview-reticulated-python/ and https://rstudio.github.io/reticulate/ and deploy the applications to RStudio Connect.
For more information on end-users working with custom, per-project Python environments, refer to the support article on Installing and Configuring Python with RStudio.
For more details on each step, refer to the concepts and best practices in the support article for Best Practices for Using Python with RStudio Connect.