Support

Configuring Python with RStudio Server Pro and RStudio Connect

Follow

Overview

You can use Python with RStudio Server Pro to develop R applications that call Python code using the reticulate package. You can use Python with RStudio Connect to publish Jupyter Notebooks as well as R applications that call Python code.

The best approach for using Python with RStudio Server Pro and RStudio Connect is to install Python from source on the server for the same reasons we recommend installing R from source. Using this approach, you can manage multiple versions of Python on the server that are independent of the system-managed version of Python.

Configuring Python with RStudio Server Pro

For RStudio Server Pro, an administration can install one or more versions of Python on the server using the following steps. Then, each user can create a virtual environment with Python to perform development work.

  1. Install one or more versions of Python from source following the steps here, including pip and virtualenv: Installing Python with RStudio Server Pro and RStudio Connect
  2. Each user can create a virtualenv in their project directory, install packages in their virtual environment and configure the RETICULATE_PYTHON environment variable following the Best Practices for using Python with RStudio Connect.

Configuring Python with RStudio Connect

For RStudio Connect, an administration can install one or more versions of Python on the server using the following steps.

RStudio Connect uses a service account (default rstudio-connect) to automatically create virtual environments in Python for each application at deployment time. As a result, it is not typically necessary to manually install Python packages or create virtual environments on the RStudio Connect server.

  1. Install one or more versions of Python from source following the steps here, including pip and virtualenv: Installing Python with RStudio Server Pro and RStudio Connect
  2. Enable Python support in the RStudio Connect configuration file to point to the versions of Python that were installed, then restart RStudio Connect: https://docs.rstudio.com/connect/admin/python.html#enabling-python-support
  3. When R applications that use Python are deployed to RStudio Connect, they will use these configured versions of Python to automatically create a virtual environment at deployment time and install the required Python packages

For more information on using Python with RStudio Connect, please see here - https://support.rstudio.com/hc/en-us/articles/360016990813-Using-Python-with-RStudio-Connect

Comments