Skip to content

Integrating Posit Workbench with Python#


These instructions describe how to use the reticulate R package with Posit Workbench, formerly RStudio Workbench, to interface with Python.

Once you configure Python and reticulate with Workbench, 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 reticulate package.

What is reticulate?#

The reticulate package provides a comprehensive set of tools for interoperability between Python and R. The package includes facilities for:

  • Calling Python from R in a variety of ways including R Markdown, sourcing Python scripts, importing Python modules, and using Python interactively within an R session.
  • Translation between R and Python objects (for example, between R and Pandas data frames, or between R matrices and NumPy arrays).
  • Flexible binding to different versions of Python including virtual environments and Conda environments.

Reticulate embeds a Python session within your R session, enabling seamless, high-performance interoperability. If you are an R developer that uses Python for some of your work or a member of data science team that uses both languages, reticulate can dramatically streamline your workflow!


The RStudio IDE uses the reticulate R package to interface with Python, and so the 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 instructions on the server with Workbench in a central location for all users (e.g., /opt/python/3.9.14/).
  • Once you have completed the steps to Install Python, continue to Step 2.

Step 2. Install reticulate for all users#

  • Install the reticulate R package for all users in the global R library.
    For example, if R is installed in /opt/R/3.9.14/, then you you can use the following command:

    $ sudo /opt/R/3.9.14/bin/Rscript -e 'install.packages("reticulate")'

Step 3. Configure reticulate with Python for all users#

  • Set the RETICULATE_PYTHON environment variable for all Workbench users by putting the following line in the R session-specific profile script used by Workbench.
    For example, if Python is installed in /opt/python/3.9.14/, then you you can use the following configuration:

    File: /etc/rstudio/rsession-profile
    export RETICULATE_PYTHON=/opt/python/3.9.14/bin/python

Next Steps#

Now, you are ready to develop Shiny apps, R Markdown, and Plumber APIs with Python/R in the RStudio IDE and Workbench using the reticulate package per and and deploy the applications to Connect.

Additional Information#

For more details on each step, refer to the concepts and best practices in the support article for Best Practices for Using Python with Connect.