Integrating RStudio Connect with Python#
These instructions describe how to install and integrate Python with RStudio Connect.
Once you configure Python with RStudio Connect, users can publish the following content:
- Jupyter Notebooks
- Flask applications
- Plotly Dash applications
- Streamlit applications
- Bokeh applications
- Mixed R and Python content using the reticulate package
Step 1. Install Python#
Install Python on the RStudio Connect server following the documented steps to Install Python.
Our recommended installation instructions for Python allow you to make multiple versions of Python available and avoid replacing existing versions of Python when updating system packages.
Ensure that you install
virtualenvin your Python environment by running the following command:Terminal
$ sudo /opt/python/3.7.7/bin/pip install virtualenv
Step 2. Install requirements for Python APIs and interactive applications#
Python APIs and interactive applications require the
libevdevelopment package to be installed:
$ sudo yum install libev-devel
$ sudo apt install libev-dev
$ sudo zypper install libev-devel
Additional RPM repositories may be required to install
CentOS 6. Please note that RStudio no longer supports
Step 3. Configure Python in RStudio Connect#
Enable Python in RStudio Connect by adding a
[Python]section to the RStudio Connect configuration file. This section should contain an
Executableoption that refers to the location of the Python executable.
For example, if you installed Python 3.7.7 on the RStudio Connect server, then your configuration file would appear as:File: /etc/rstudio-connect/rstudio-connect.gcfg
[Python] Enabled = true Executable = /opt/python/3.7.7/bin/python
(Optional) Install additional versions of Python#
To make additional versions of Python available alongside existing versions, repeat the above steps to install a different version of Python to other locations.
Then, add a new line to the RStudio Connect configuration file with the
Executableoption for each additional version of Python that you installed.
For example, if you installed Python 2.7.16, 3.6.5, and 3.7.7 on the RStudio Connect server, then your configuration file would appear as:File: /etc/rstudio-connect/rstudio-connect.gcfg
[Python] Enabled = true Executable = /opt/python/2.7.16/bin/python Executable = /opt/python/3.6.5/bin/python Executable = /opt/python/3.7.7/bin/python
For more information on best practices for end users when working with Python and RStudio Connect, refer to the support article on Best Practices for using Python with RStudio Connect.